Esempio n. 1
0
        private static void Initialize()
        {
            if (Active || isApplicationQuitting)
            {
                return;
            }

            // try to get existing manager
            var instances = FindObjectsOfType <StereoRenderManager>();

            if (instances.Length > 0)
            {
                instance = instances[0];
                if (instances.Length > 1)
                {
                    Debug.LogError("Multiple StereoRenderManager is not supported.");
                }
            }

            // pop warning if no VR device detected
#if (!(UNITY_ANDROID && VIVE_STEREO_WAVEVR))
    #if UNITY_2017_2_OR_NEWER
            if (!UnityEngine.XR.XRSettings.enabled)
            {
                Debug.LogError("VR is not enabled for this application.");
            }
    #else
            if (!UnityEngine.VR.VRSettings.enabled)
            {
                Debug.LogError("VR is not enabled for this application.");
            }
    #endif
#endif

            // get HMD head
            Camera head = GetHmdRig();
            if (head == null)
            {
                return;
            }
            if (head.transform.parent == null)
            {
                Debug.LogError("HMD rig is not of proper hierarchy. You need a \"rig\" object as its root.");
                return;
            }

            // if no exsiting instance, attach a new one to HMD camera
            if (!Active)
            {
                instance = head.gameObject.AddComponent <StereoRenderManager>();
            }

            // record camera components
            if (Active)
            {
                mainCamera       = head;
                mainCameraParent = head.transform.parent.gameObject;
            }
        }
        private static void Initialize()
        {
            if (Active || isApplicationQuitting)
            {
                return;
            }

            // try to get existing manager
            var instances = FindObjectsOfType <StereoRenderManager>();

            if (instances.Length > 0)
            {
                instance = instances[0];
                if (instances.Length > 1)
                {
                    Debug.LogError("Multiple StereoRenderManager is not supported.");
                }
            }

            // pop warning if no VR device detected
            #if UNITY_5_4_OR_NEWER
            if (!UnityEngine.XR.XRSettings.enabled)
            {
                Debug.LogError("VR is not enabled for this application.");
            }
            #endif

            // try to get HMD camera
            Camera mainCam = GetHmdCamera();
            if (mainCam == null)
            {
                return;
            }
            if (mainCam.transform.parent == null)
            {
                Debug.LogError("HMD Camera is not in proper hierarchy. You need a \"rig\" object as its parent.");
                return;
            }

            // if no exsiting instance, attach a new one to HMD camera
            if (!Active)
            {
                instance = mainCam.gameObject.AddComponent <StereoRenderManager>();
            }

            // record camera components
            if (Active)
            {
                mainCamera       = mainCam;
                mainCameraParent = mainCam.transform.parent.gameObject;
            }
        }