예제 #1
0
 private void Update()
 {
     if (NxrInput.GetKeyUp(CKeyEvent.KEYCODE_BACK) ||
         NxrInput.GetControllerKeyUp(CKeyEvent.KEYCODE_CONTROLLER_MENU) ||
         NxrInput.GetControllerKeyUp(CKeyEvent.KEYCODE_CONTROLLER_MENU,
                                     InteractionManager.NACTION_HAND_TYPE.HAND_LEFT) ||
         NxrInput.GetControllerKeyUp(CKeyEvent.KEYCODE_CONTROLLER_MENU,
                                     InteractionManager.NACTION_HAND_TYPE.HAND_RIGHT))
     {
         // 返回键
         Debug.Log("Update->OnGazeTrigger");
         OnGazeTrigger();
     }
 }
예제 #2
0
        // Update is called once per frame
        void Update()
        {
            //GameObject controllerDot = NibiruAxis.NxrPlayerCtrl.Instance.GetControllerLaserDot();
            //if (controllerDot != null)
            //{
            //    Debug.Log("Contoller Dot:" + controllerDot.transform.position.ToString());
            //}
            //NxrReticle reticle = NxrViewer.Instance.GetNxrReticle();
            //if (reticle.IsShowing())
            //{
            //    Debug.Log("Reticle:" + reticle.GetReticlePointer().transform.position.ToString());
            //}

            if (NxrInput.GetKeyDown(CKeyEvent.KEYCODE_DPAD_CENTER))
            {
                textMesh.text = "HMD Enter : Down";
            }

            if (NxrInput.GetKeyPressed(CKeyEvent.KEYCODE_DPAD_CENTER))
            {
                textMesh.text = "HMD Enter : Pressed";
            }

            if (NxrInput.GetKeyUp(CKeyEvent.KEYCODE_DPAD_CENTER))
            {
                textMesh.text = "HMD Enter  : Up";
            }

            if (NxrInput.GetKeyDown(CKeyEvent.KEYCODE_BACK))
            {
                textMesh.text = "HMD Back : Down";
            }

            if (NxrInput.GetKeyPressed(CKeyEvent.KEYCODE_BACK))
            {
                textMesh.text = "HMD Back : Pressed";
            }

            if (NxrInput.GetKeyUp(CKeyEvent.KEYCODE_BACK))
            {
                textMesh.text = "HMD Back : Up";
            }

            if (NxrInput.GetKeyDown(CKeyEvent.KEYCODE_DPAD_LEFT))
            {
                textMesh.text = "HMD Left : Down";
            }

            if (NxrInput.GetKeyPressed(CKeyEvent.KEYCODE_DPAD_LEFT))
            {
                textMesh.text = "HMD Left : Pressed";
            }

            if (NxrInput.GetKeyUp(CKeyEvent.KEYCODE_DPAD_LEFT))
            {
                textMesh.text = "HMD Left : Up";
            }

            if (NxrInput.GetKeyDown(CKeyEvent.KEYCODE_DPAD_RIGHT))
            {
                textMesh.text = "HMD Right : Down";
            }

            if (NxrInput.GetKeyPressed(CKeyEvent.KEYCODE_DPAD_RIGHT))
            {
                textMesh.text = "HMD Right : Pressed";
            }

            if (NxrInput.GetKeyUp(CKeyEvent.KEYCODE_DPAD_RIGHT))
            {
                textMesh.text = "HMD Right : Up";
            }

            if (NxrInput.GetKeyDown(CKeyEvent.KEYCODE_DPAD_UP))
            {
                textMesh.text = "HMD Up : Down";
            }

            if (NxrInput.GetKeyPressed(CKeyEvent.KEYCODE_DPAD_UP))
            {
                textMesh.text = "HMD Up : Pressed";
            }

            if (NxrInput.GetKeyUp(CKeyEvent.KEYCODE_DPAD_UP))
            {
                textMesh.text = "HMD Up : Up";
            }

            if (NxrInput.GetKeyDown(CKeyEvent.KEYCODE_DPAD_DOWN))
            {
                textMesh.text = "HMD Down : Down";
            }

            if (NxrInput.GetKeyPressed(CKeyEvent.KEYCODE_DPAD_DOWN))
            {
                textMesh.text = "HMD Down : Pressed";
            }

            if (NxrInput.GetKeyUp(CKeyEvent.KEYCODE_DPAD_DOWN))
            {
                textMesh.text = "HMD Down : Up";
            }

            // 3DOF Controller
            if (InteractionManager.Is3DofControllerConnected())
            {
                InteractionManager.NACTION_HAND_TYPE mHandType = InteractionManager.GetHandTypeByHandMode();
                TextMesh textMeshController = textMeshControllerRight;
                if (mHandType == InteractionManager.NACTION_HAND_TYPE.HAND_LEFT)
                {
                    textMeshController = textMeshControllerLeft;
                }

                bool HasKeyDown = false;
                for (int i = 0, size = threeDofCtrlKeyCode.Length; i < size; i++)
                {
                    int    keyCode = threeDofCtrlKeyCode[i];
                    string keyStr  = threeDofCtrlKeyStr[i];
                    if (NxrInput.GetControllerKeyDown(keyCode))
                    {
                        textMeshController.text = keyStr + "Down_" + mHandType.ToString();
                        HasKeyDown = true;
                    }

                    if (!HasKeyDown && NxrInput.GetControllerKeyPressed(keyCode))
                    {
                        textMeshController.text = keyStr + "Pressed_" + mHandType.ToString();
                        HasKeyDown = true;
                    }

                    if (!HasKeyDown)
                    {
                        if (NxrInput.GetControllerKeyUp(keyCode))
                        {
                            textMeshController.text = keyStr + "Up_" + mHandType.ToString();
                        }
                    }
                }
            }
            else
            {
                // SixDof Controller
                foreach (InteractionManager.NACTION_HAND_TYPE HandType in handTypes)
                {
                    TextMesh textMeshCtrl = null;
                    if (HandType == InteractionManager.NACTION_HAND_TYPE.HAND_LEFT)
                    {
                        textMeshCtrl = textMeshControllerLeft;
                    }
                    else
                    {
                        textMeshCtrl = textMeshControllerRight;
                    }

                    bool HasKeyDown = false;
                    for (int i = 0, size = sixDofCtrlKeyCode.Length; i < size; i++)
                    {
                        int    keyCode = sixDofCtrlKeyCode[i];
                        string keyStr  = sixDofCtrlKeyStr[i];
                        if (NxrInput.GetControllerKeyDown(keyCode, HandType))
                        {
                            textMeshCtrl.text = keyStr + "Down_" + HandType.ToString();
                            HasKeyDown        = true;
                        }

                        if (!HasKeyDown && NxrInput.GetControllerKeyPressed(keyCode, HandType))
                        {
                            textMeshCtrl.text = keyStr + "Pressed_" + HandType.ToString();
                            HasKeyDown        = true;
                        }

                        if (!HasKeyDown)
                        {
                            if (NxrInput.GetControllerKeyUp(keyCode, HandType))
                            {
                                textMeshCtrl.text = keyStr + "Up_" + HandType.ToString();
                            }
                        }
                    }
                }
            }
        }