
SteamVR_LaserPointer是自带的脚本直接挂上就行
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
using Valve.VR.Extras;
//写的一个控制射线关闭开启的功能
public class LaserPointer_Chh : MonoBehaviour
{
public SteamVR_LaserPointer SteamVrLaserPointer;
/// <summary>
/// 什么类型的按键
/// </summary>
public SteamVR_Action_Boolean disk;
void Start()
{
if (SteamVrLaserPointer == null)
SteamVrLaserPointer = this.GetComponent<SteamVR_LaserPointer>();
}
void Update()
{
//SteamVR_Input_Sources.RightHand 只获取右手的
if (disk.GetStateDown(SteamVR_Input_Sources.RightHand))
{
//按下圆盘开启射线
OpenLaserPointer();
}
if (disk.GetStateUp(SteamVR_Input_Sources.RightHand))

本文介绍了如何利用SteamVR_LaserPointer内置脚本,结合自定义的PlayerUIButton脚本来响应手柄按键事件,实现通过射线控制UGUI按钮的点击操作。
最低0.47元/天 解锁文章
4969

被折叠的 条评论
为什么被折叠?



