1. 程式人生 > >Unity獲取NoloVR手柄

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
    }
}