Exemple #1
0
        public void OnDisable()
        {
            onDisable();

            EditorApplication.playmodeStateChanged -= OnPlaymodeStateChanged;

            VRSettings.StopRenderingToDevice();

            SetOtherViewsEnabled(true);

            if (m_CameraPivot)
            {
                DestroyImmediate(m_CameraPivot.gameObject, true);
            }

            Assert.IsNotNull(s_ActiveView, "EditorVR should have an active view");
            s_ActiveView = null;
        }
Exemple #2
0
        private const float kHMDActivityTimeout    = 3f;      // in seconds

        public void OnEnable()
        {
            EditorApplication.playmodeStateChanged += OnPlaymodeStateChanged;

            Assert.IsNull(s_ActiveView, "Only one EditorVR should be active");

            autoRepaintOnSceneChange = true;
            wantsMouseMove           = true;
            s_ActiveView             = this;

            GameObject cameraGO = EditorUtility.CreateGameObjectWithHideFlags("EditorVRCamera", EditorVR.kDefaultHideFlags, typeof(Camera));

            m_Camera            = cameraGO.GetComponent <Camera>();
            m_Camera.enabled    = false;
            m_Camera.cameraType = CameraType.VR;

            GameObject pivotGO = EditorUtility.CreateGameObjectWithHideFlags("EditorVRCameraPivot", EditorVR.kDefaultHideFlags, typeof(EditorMonoBehaviour));

            m_CameraPivot             = pivotGO.transform;
            m_Camera.transform.parent = m_CameraPivot;
            m_Camera.nearClipPlane    = 0.01f;
            m_Camera.farClipPlane     = 1000f;

            // Generally, we want to be at a standing height, so default to that
            const float kHeadHeight = 1.7f;
            Vector3     position    = m_CameraPivot.position;

            position.y             = kHeadHeight;
            m_CameraPivot.position = position;
            m_CameraPivot.rotation = Quaternion.identity;

            // Disable other views to increase rendering performance for EditorVR
            SetOtherViewsEnabled(false);

            VRSettings.StartRenderingToDevice();
            InputTracking.Recenter();

            onEnable();
        }