示例#1
0
 private void OnDestroy()
 {
     if (nibiruService != null)
     {
         nibiruService.UnRegisterSensorListener();
     }
 }
示例#2
0
        public void OnGazeTrigger()
        {
            NibiruService nibiruService = NxrViewer.Instance.GetNibiruService();

            // if (nibiruService != null && gameObject.name.Equals("CubeTouchCursor"))
            // {
            //     cursorEnabled = !cursorEnabled;
            //     nibiruService.SetEnableTouchCursor(cursorEnabled);
            // }
            // else if (nibiruService != null && gameObject.name.Equals("CubeDisplayMode"))
            // {
            //     curMode = curMode == DISPLAY_MODE.MODE_3D ? DISPLAY_MODE.MODE_2D : DISPLAY_MODE.MODE_3D;
            //     nibiruService.SetDisplayMode(curMode);
            // }
            if (nibiruService != null && gameObject.name.Equals("CubeBrightnessUp"))
            {
                nibiruService.SetBrightnessValue(nibiruService.GetBrightnessValue() + 1);
            }
            else if (nibiruService != null && gameObject.name.Equals("CubeBrightnessDown"))
            {
                nibiruService.SetBrightnessValue(nibiruService.GetBrightnessValue() - 1);
            }
            // else if (gameObject.name.Equals("CubeLanguageCN"))
            // {
            //     NxrViewer.Instance.VoiceLanguage = VOICE_LANGUAGE.CHINESE;
            //
            //     gameObject.GetComponent<Renderer>().material.color = Color.green;
            //
            //     GameObject cnObj = GameObject.Find("CubeLanguageEN");
            //     if (cnObj != null)
            //     {
            //         cnObj.GetComponent<Renderer>().material.color = Color.white;
            //     }
            //     // resume
            //     Transform rootTransform = GameObject.Find("UIRoot").transform;
            //     rootTransform.Find("CubeNextDemo").transform.gameObject.SetActive(true);
            //
            //     // refresh
            //     UpdateTextContent(LocalizationManager.chinese);
            //
            //     LocalizationManager.GetInstance.ChangeLanguage(LocalizationManager.chinese);
            // }
            // else if (gameObject.name.Equals("CubeLanguageEN"))
            // {
            //     NxrViewer.Instance.VoiceLanguage = VOICE_LANGUAGE.ENGLISH;
            //     gameObject.GetComponent<Renderer>().material.color = Color.green;
            //     GameObject enObj = GameObject.Find("CubeLanguageCN");
            //     if (enObj != null)
            //     {
            //         enObj.GetComponent<Renderer>().material.color = Color.white;
            //     }
            //
            //     if (GetPageNumber() == 2)
            //     {
            //         Transform rootTransform = GameObject.Find("UIRoot").transform;
            //         // dismiss
            //         rootTransform.Find("CubeNextDemo").transform.gameObject.SetActive(false);
            //     }
            //
            //     // refresh
            //     UpdateTextContent(LocalizationManager.english);
            //
            //     LocalizationManager.GetInstance.ChangeLanguage(LocalizationManager.english);
            // }
            else if (nibiruService != null && gameObject.name.Equals("CameraStart"))
            {
                // camera preview
                hasTrigger = false;
                nibiruService.GetCameraStatus();
            }
            else if (nibiruService != null && gameObject.name.Equals("CameraPause"))
            {
                nibiruService.StopCamereaPreView();
            }
            // else if (gameObject.name.Equals("CubeNextDemo"))
            // {
            //     int page = GetPageNumber();
            //     if (page == 0 || page == 2)
            //     {
            //         UpdateVoiceApiDemoPage(true);
            //         // dismiss text
            //         Transform rootTransform = GameObject.Find("UIRoot").transform;
            //         rootTransform.Find("TextControlTip").gameObject.SetActive(false);
            //         rootTransform.Find("TextTip").gameObject.SetActive(false);
            //         // dismiss progressbar
            //         Transform parentTransform = GameObject.Find("VolumeRoot").transform;
            //         parentTransform.Find("VolumeIcon").gameObject.SetActive(false);
            //         parentTransform.Find("VolumeProgressBG").gameObject.SetActive(false);
            //         parentTransform.Find("VolumeProgressValue").gameObject.SetActive(false);
            //         // change en/cn
            //         rootTransform.Find("CubeLanguageEN").transform.gameObject.SetActive(true);
            //         rootTransform.Find("CubeLanguageCN").transform.gameObject.SetActive(true);
            //         return;
            //     }
            //     else if (page == 1)
            //     {
            //         UpdateVoiceApiDemoPage(false);
            //         // resume text
            //         Transform rootTransform = GameObject.Find("UIRoot").transform;
            //         rootTransform.Find("TextControlTip").gameObject.SetActive(true);
            //         rootTransform.Find("TextTip").gameObject.SetActive(true);
            //     }
            //
            //     // next page
            //     LocalizationText localizationText = GameObject.Find("TextControlTip").GetComponent<LocalizationText>();
            //     string newKey = localizationText.key == "voice_say_content" ? "voice_say_content_volume" : "voice_say_content";
            //     localizationText.UpdateKey(newKey);
            //
            //
            //     //Debug.Log("-------------------:www---------------" + newKey);
            //
            //     // back
            //     LocalizationText localizationTextNxt = GameObject.Find("TextNextDemo").GetComponent<LocalizationText>();
            //     newKey = localizationTextNxt.key == "next_demo_text" ? "last_demo_text" : "next_demo_text";
            //     localizationTextNxt.UpdateKey(newKey);
            //
            //     LocalizationText localizationTextTip = GameObject.Find("TextTip").GetComponent<LocalizationText>();
            //     newKey = localizationTextTip.key == "voice_tip_content" ? "voice_tip_content_v" : "voice_tip_content";
            //     localizationTextTip.UpdateKey(newKey);
            //
            //     if (newKey == "voice_tip_content_v")
            //     {
            //         Transform rootTransform = GameObject.Find("UIRoot").transform;
            //
            //         // dismiss en button
            //         rootTransform.Find("CubeLanguageEN").transform.gameObject.SetActive(false);
            //         rootTransform.Find("CubeLanguageCN").transform.gameObject.SetActive(false);
            //         //
            //         // show progressbar
            //         Transform parentTransform = GameObject.Find("VolumeRoot").transform;
            //         parentTransform.Find("VolumeIcon").gameObject.SetActive(true);
            //         parentTransform.Find("VolumeProgressBG").gameObject.SetActive(true);
            //         parentTransform.Find("VolumeProgressValue").gameObject.SetActive(true);
            //
            //         UpdateVolumeProgress();
            //     }
            //     else if (newKey == "voice_tip_content")
            //     {
            //         Transform rootTransform = GameObject.Find("UIRoot").transform;
            //         rootTransform.Find("CubeLanguageEN").transform.gameObject.SetActive(true);
            //         rootTransform.Find("CubeLanguageCN").transform.gameObject.SetActive(true);
            //         //
            //         // dismiss progressbar
            //         Transform parentTransform = GameObject.Find("VolumeRoot").transform;
            //         parentTransform.Find("VolumeIcon").gameObject.SetActive(false);
            //         parentTransform.Find("VolumeProgressBG").gameObject.SetActive(false);
            //         parentTransform.Find("VolumeProgressValue").gameObject.SetActive(false);
            //     }
            //
            //     page++;
            // }
            else if (nibiruService != null && gameObject.name.Equals("CubeStartSensor"))
            {
                nibiruService.RegisterSensorListener(SENSOR_TYPE.ACCELEROMETER, SENSOR_LOCATION.HMD);
                nibiruService.RegisterSensorListener(SENSOR_TYPE.GYROSCOPE, SENSOR_LOCATION.HMD);
                nibiruService.RegisterSensorListener(SENSOR_TYPE.MAGNETIC_FIELD, SENSOR_LOCATION.HMD);
            }
            else if (nibiruService != null && gameObject.name.Equals("CubeStopSensor"))
            {
                nibiruService.UnRegisterSensorListener();
            }
            // else if (nibiruService != null && gameObject.name.Equals("ButtonStopRec"))
            // {
            //     nibiruService.StopVoiceRecording();
            // }
            // else if (gameObject.name.Equals("ButtonStartRec"))
            // {
            //     //nibiruService.StartVoiceRecording();
            //     Transform btnTransform = gameObject.transform.Find("ApiButtonText");
            //     LocalizationText localizationText = btnTransform.gameObject.GetComponent<LocalizationText>();
            //     localizationText.UpdateKey("voice_say_content_3");
            // }
        }