//1眼/2眼の切り替え. public void SwitchEyeMode(EyeMode eyeMode) { if (EyeMode.TwoEyes == eyeMode) { singleCamera.enabled = false; leftEyeCamera.enabled = true; rightEyeCamera.enabled = true; } else { singleCamera.enabled = true; leftEyeCamera.enabled = false; rightEyeCamera.enabled = false; } prevEyeMode = currentEyeMode; currentEyeMode = eyeMode; return; }
private void Awake( ) { //デフォルトで自動スリープを無効化しておく. Screen.sleepTimeout = SleepTimeout.NeverSleep; //子となるカメラを一度全て無効にしておく. Camera[] childCameraArray; childCameraArray = GetComponentsInChildren <Camera>( ); foreach (Camera camera in childCameraArray) { if (gameObject != camera.gameObject) { camera.enabled = false; } } //ARカメラ用に紐づけるARKit/ARCore用コンポーネントを設定する. #if UNITY_ANDROID if (null != arBackgroundMaterial) { singleCamera.gameObject.SetActive(false); leftEyeCamera.gameObject.SetActive(false); rightEyeCamera.gameObject.SetActive(false); singleArCameraBackground = singleCamera.gameObject.AddComponent <GoogleARCore.ARCoreBackgroundRenderer>( ); leftArCameraBackground = leftEyeCamera.gameObject.AddComponent <GoogleARCore.ARCoreBackgroundRenderer>( ); rightArCameraBackground = rightEyeCamera.gameObject.AddComponent <GoogleARCore.ARCoreBackgroundRenderer>( ); singleArCameraBackground.BackgroundMaterial = arBackgroundMaterial; leftArCameraBackground.BackgroundMaterial = arBackgroundMaterial; rightArCameraBackground.BackgroundMaterial = arBackgroundMaterial; singleCamera.gameObject.SetActive(true); leftEyeCamera.gameObject.SetActive(true); rightEyeCamera.gameObject.SetActive(true); } #elif UNITY_IOS if (null != arBackgroundMaterial) { singleCamera.gameObject.SetActive(false); leftEyeCamera.gameObject.SetActive(false); rightEyeCamera.gameObject.SetActive(false); singleArCameraBackground = singleCamera.gameObject.AddComponent <HologlaARKitVideo>( ); leftArCameraBackground = leftEyeCamera.gameObject.AddComponent <HologlaARKitVideo>( ); rightArCameraBackground = rightEyeCamera.gameObject.AddComponent <HologlaARKitVideo>( ); singleArCameraBackground.m_ClearMaterial = arBackgroundMaterial; leftArCameraBackground.m_ClearMaterial = arBackgroundMaterial; rightArCameraBackground.m_ClearMaterial = arBackgroundMaterial; singleCamera.gameObject.SetActive(true); leftEyeCamera.gameObject.SetActive(true); rightEyeCamera.gameObject.SetActive(true); } #endif currentViewMode = UserSettings.viewMode; currentEyeMode = UserSettings.eyeMode; interpupillaryDistance = UserSettings.interpupillaryDistance; currentViewSize = UserSettings.viewSize; SwitchViewMode(currentViewMode); SwitchEyeMode(currentEyeMode); ApplyIPD(interpupillaryDistance); SwitchViewSize(currentViewSize); return; }
private void Awake( ) { //デフォルトで自動スリープを無効化しておく. Screen.sleepTimeout = SleepTimeout.NeverSleep; //子となるカメラを一度全て無効にしておく. Camera[] childCameraArray; childCameraArray = GetComponentsInChildren <Camera>( ); foreach (Camera camera in childCameraArray) { if (gameObject != camera.gameObject) { camera.enabled = false; } } //ARカメラ用に紐づけるARKit/ARCore用コンポーネントを設定する. #if UNITY_ANDROID if (null != arBackgroundMaterial) { singleCamera.gameObject.SetActive(true); leftEyeCamera.gameObject.SetActive(true); rightEyeCamera.gameObject.SetActive(true); } #elif UNITY_IOS if (null != arBackgroundMaterial) { singleCamera.gameObject.SetActive(true); leftEyeCamera.gameObject.SetActive(true); rightEyeCamera.gameObject.SetActive(true); } #endif if (null == arCameraBackgroundArray) { arCameraBackgroundArray = GetComponentsInChildren <ARCameraBackground>(true); } foreach (ARCameraBackground arCameraBackground in arCameraBackgroundArray) { arCameraBackground.useCustomMaterial = true; arCameraBackground.customMaterial = arBackgroundMaterial; } currentViewMode = UserSettings.viewMode; currentEyeMode = UserSettings.eyeMode; interpupillaryDistance = UserSettings.interpupillaryDistance; currentViewSize = UserSettings.viewSize; SwitchViewMode(currentViewMode); SwitchEyeMode(currentEyeMode); ApplyIPD(interpupillaryDistance); SwitchViewSize(currentViewSize); #if UNITY_EDITOR if (null != transform.parent.gameObject && null == transform.parent.gameObject.GetComponent <EditorCameraController>( )) { transform.parent.gameObject.AddComponent <EditorCameraController>( ); } #endif return; }