Example #1
0
        void Update()
        {
            if (!customModel)
            {
                if (hand == PXR_Input.Controller.LeftController)
                {
                    if (PXR_Input.IsControllerConnected(PXR_Input.Controller.LeftController))
                    {
                        if (!leftControllerState)
                        {
                            controllerType = PXR_Plugin.Controller.UPxr_GetControllerType();
                            RefreshController(PXR_Input.Controller.LeftController);
                            leftControllerState = true;
                        }
                    }
                    else
                    {
                        if (leftControllerState)
                        {
                            DestroyLocalController();
                            leftControllerState = false;
                        }
                    }
                }

                if (hand == PXR_Input.Controller.RightController)
                {
                    if (PXR_Input.IsControllerConnected(PXR_Input.Controller.RightController))
                    {
                        if (!rightControllerState)
                        {
                            controllerType = PXR_Plugin.Controller.UPxr_GetControllerType();
                            RefreshController(PXR_Input.Controller.RightController);
                            rightControllerState = true;
                        }
                    }
                    else
                    {
                        if (rightControllerState)
                        {
                            DestroyLocalController();
                            rightControllerState = false;
                        }
                    }
                }
            }
        }
Example #2
0
        void Start()
        {
            controllerType = PXR_Plugin.Controller.UPxr_GetControllerType();
            if (!customModel)
            {
#if UNITY_ANDROID && !UNITY_EDITOR
                LoadResFromJson();
#endif
                leftControllerState  = PXR_Input.IsControllerConnected(PXR_Input.Controller.LeftController);
                rightControllerState = PXR_Input.IsControllerConnected(PXR_Input.Controller.RightController);
                if (hand == PXR_Input.Controller.LeftController)
                {
                    RefreshController(PXR_Input.Controller.LeftController);
                }
                if (hand == PXR_Input.Controller.RightController)
                {
                    RefreshController(PXR_Input.Controller.RightController);
                }
            }
        }
Example #3
0
 private void RefreshController(PXR_Input.Controller hand)
 {
     if (PXR_Input.IsControllerConnected(hand))
     {
         if (systemOrLocal == 0)
         {
             LoadControllerFromPrefab(hand);
             if (!loadModelSuccess)
             {
                 LoadControllerFromSystem((int)hand);
             }
         }
         else
         {
             var isControllerExist = false;
             foreach (Transform t in transform)
             {
                 if (t.name == modelName)
                 {
                     isControllerExist = true;
                 }
             }
             if (!isControllerExist)
             {
                 LoadControllerFromSystem((int)hand);
                 if (!loadModelSuccess)
                 {
                     LoadControllerFromPrefab(hand);
                 }
             }
             else
             {
                 var currentController = transform.Find(modelName);
                 currentController.gameObject.SetActive(true);
             }
         }
         PXR_ControllerKeyTips.RefreshTips();
     }
 }
        // Update is called once per frame
        void Update()
        {
            //set controller data to boundary
            fixedData = PXR_Plugin.Controller.UPxr_GetControllerFixedSensorState(0);
            PXR_Plugin.Boundary.UPxr_SetReinPosition(fixedData[0], fixedData[1], fixedData[2], fixedData[3], fixedData[4], fixedData[5], fixedData[6], 0, PXR_Input.IsControllerConnected(PXR_Input.Controller.LeftController), 0);
            fixedData = PXR_Plugin.Controller.UPxr_GetControllerFixedSensorState(1);
            PXR_Plugin.Boundary.UPxr_SetReinPosition(fixedData[0], fixedData[1], fixedData[2], fixedData[3], fixedData[4], fixedData[5], fixedData[6], 1, PXR_Input.IsControllerConnected(PXR_Input.Controller.RightController), 0);

            // boundary
            if (eyeCamera != null && eyeCamera.enabled)
            {
                int currentBoundaryState = PXR_Plugin.Boundary.UPxr_GetSeeThroughState();

                if (currentBoundaryState != lastBoundaryState)
                {
                    if (currentBoundaryState == 2) // close camera render(close camera render) and limit framerate(if needed)
                    {
                        // record
                        eyeCameraOriginCullingMask     = eyeCamera.cullingMask;
                        eyeCameraOriginClearFlag       = eyeCamera.clearFlags;
                        eyeCameraOriginBackgroundColor = eyeCamera.backgroundColor;

                        // close render
                        eyeCamera.cullingMask     = 0;
                        eyeCamera.clearFlags      = CameraClearFlags.SolidColor;
                        eyeCamera.backgroundColor = Color.black;
                    }
                    else if (currentBoundaryState == 1) // open camera render, but limit framerate(if needed)
                    {
                        if (lastBoundaryState == 2)
                        {
                            if (eyeCamera.cullingMask == 0)
                            {
                                eyeCamera.cullingMask = eyeCameraOriginCullingMask;
                            }
                            if (eyeCamera.clearFlags == CameraClearFlags.SolidColor)
                            {
                                eyeCamera.clearFlags = eyeCameraOriginClearFlag;
                            }
                            if (eyeCamera.backgroundColor == Color.black)
                            {
                                eyeCamera.backgroundColor = eyeCameraOriginBackgroundColor;
                            }
                        }
                    }
                    else // open camera render(recover)
                    {
                        if ((lastBoundaryState == 2 || lastBoundaryState == 1))
                        {
                            if (eyeCamera.cullingMask == 0)
                            {
                                eyeCamera.cullingMask = eyeCameraOriginCullingMask;
                            }
                            if (eyeCamera.clearFlags == CameraClearFlags.SolidColor)
                            {
                                eyeCamera.clearFlags = eyeCameraOriginClearFlag;
                            }
                            if (eyeCamera.backgroundColor == Color.black)
                            {
                                eyeCamera.backgroundColor = eyeCameraOriginBackgroundColor;
                            }
                        }
                    }
                    lastBoundaryState = currentBoundaryState;
                }
            }
        }