Unity获取NoloVR手柄

这里对NoloVR的手柄获取进行了搬移记录,来自官方文档;

记得去官方去下载插件导入哦;不然没有NoloVR类;

https://www.nolovr.com/003_3_1?treeidp=003&treeid=303

public class Input_Test : MonoBehaviour {
	void Update () {
        //右手手柄
        #region right 
        //右手手柄 TouchPad键按下
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonDown(NoloButtonID.TouchPad))
        {
            Debug.Log("RightController TouchPad Down");
        }
        //右手手柄 TouchPad键按压中
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonPressed(NoloButtonID.TouchPad))
        {
            Debug.Log("RightController TouchPad Pressed");
        }
        //右手手柄 TouchPad键抬起
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonUp(NoloButtonID.TouchPad))
        {
            Debug.Log("RightController TouchPad Up");
        }

        //右手手柄 Trigger键按下
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonDown(NoloButtonID.Trigger))
        {
            Debug.Log("RightController Trigger Down");
        }
        //右手手柄 Trigger键按压中
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonPressed(NoloButtonID.Trigger))
        {
            Debug.Log("RightController Trigger Pressed");
            NoloVR_Controller.GetDevice(NoloDeviceType.RightController).TriggerHapticPulse(100);
        }
        //右手手柄 TouchPad键抬起
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonUp(NoloButtonID.Trigger))
        {
            Debug.Log("RightController Trigger Up");
        }


        //右手手柄 System键按下
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonDown(NoloButtonID.System))
        {
            Debug.Log("RightController System Down");
        }
        //右手手柄 System键按压中
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonPressed(NoloButtonID.System))
        {
            Debug.Log("RightController System Pressed");
        }
        //右手手柄 System键抬起
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonUp(NoloButtonID.System))
        {
            Debug.Log("RightController System Up");
        }


        //右手手柄 Menu键按下
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonDown(NoloButtonID.Menu))
        {
            Debug.Log("RightController Menu Down");
        }
        //右手手柄 Menu键按压中
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonPressed(NoloButtonID.Menu))
        {
            Debug.Log("RightController Menu Pressed");
        }
        //右手手柄 Menu键抬起
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonUp(NoloButtonID.Menu))
        {
            Debug.Log("RightController Menu Up");
        }


        //右手手柄 Grip键按下
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonDown(NoloButtonID.Grip))
        {
            Debug.Log("RightController Grip Down");
        }
        //右手手柄 Grip键按压中
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonPressed(NoloButtonID.Grip))
        {
            Debug.Log("RightController Grip Pressed");
        }
        //右手手柄 Grip键抬起
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonUp(NoloButtonID.Grip))
        {
            Debug.Log("RightController Grip Up");
        }
        //获取右手手柄Grip面板坐标 vector2类型
        if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloTouchPressed(NoloTouchID.TouchPad))
        {
            Debug.Log(NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetAxis());
        }
        #endregion

        //左手同上不在说明
        #region left
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonDown(NoloButtonID.TouchPad))
        {
            Debug.Log("LeftController TouchPad Down");
        }
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonPressed(NoloButtonID.TouchPad))
        {
            Debug.Log("LeftController TouchPad Pressed");
        }
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonUp(NoloButtonID.TouchPad))
        {
            Debug.Log("LeftController TouchPad Up");
        }


        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonDown(NoloButtonID.Trigger))
        {
            Debug.Log("LeftController Trigger Down");
        }
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonPressed(NoloButtonID.Trigger))
        {
            NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).TriggerHapticPulse(100);
            Debug.Log("LeftController Trigger Pressed");
        }
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonUp(NoloButtonID.Trigger))
        {
            Debug.Log("LeftController Trigger Up");
        }



        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonDown(NoloButtonID.System))
        {
            Debug.Log("LeftController System Down");
        }
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonPressed(NoloButtonID.System))
        {
            Debug.Log("LeftController System Pressed");
        }
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonUp(NoloButtonID.System))
        {
            Debug.Log("LeftController System Up");
        }



        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonDown(NoloButtonID.Menu))
        {
            Debug.Log("LeftController Menu Down");
        }
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonPressed(NoloButtonID.Menu))
        {
            Debug.Log("LeftController Menu Pressed");
        }
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonUp(NoloButtonID.Menu))
        {
            Debug.Log("LeftController Menu Up");
        }



        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonDown(NoloButtonID.Grip))
        {
            Debug.Log("LeftController Grip Down");
        }
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonPressed(NoloButtonID.Grip))
        {
            Debug.Log("LeftController Grip Pressed");
        }
        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonUp(NoloButtonID.Grip))
        {
            Debug.Log("LeftController Grip Up");
        }

        if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloTouchPressed(NoloTouchID.TouchPad))
        {
            Debug.Log(NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetAxis());
            
        }
        #endregion
    }
}

 

你可能感兴趣的:(VR开发)