public override void StartController(InstantVR ivr)
        {
            base.StartController(ivr);
#if UNITY_ANDROID
            if (extension == null)
            {
                extension = ivr.GetComponent <IVR_Cardboard>();
            }

            Camera camera = CheckCamera();
            if (camera != null)
            {
                cameraTransform = camera.transform;
                neck2eyes       = HeadUtils.GetNeckEyeDelta(ivr);

                cameraTransform.gameObject.SetActive(false);

                GvrViewer cardboardPrefab = Resources.Load <GvrViewer>("CardboardPrefab");
                cardboard = Instantiate(cardboardPrefab);
                if (cardboard == null)
                {
                    Debug.LogError("Could not instantiate Cardboard. CardboardCameraRig is missing?");
                }
                else
                {
                    cameraRoot = cardboard.gameObject;
                    cameraRoot.transform.parent = ivr.transform;

                    cameraRoot.transform.position = transform.position;
                    cameraRoot.transform.rotation = ivr.transform.rotation;

                    GvrHead gvrHead = cardboard.GetComponentInChildren <GvrHead>();
                    if (gvrHead != null)
                    {
                        camera          = Camera.main;
                        cameraTransform = Camera.main.transform;
                    }
                }
            }
            controller = Controllers.GetController(0);
#if INSTANTVR_ADVANCED
            vicoVRHead = GetComponent <IVR_VicoVRHead>();
#endif
#endif
        }
예제 #2
0
        public override void StartController(InstantVR ivr)
        {
            if (extension == null)
            {
                extension = ivr.GetComponent <IVR_UnityVR>();
            }

#if UNITY_IOS
            extension.present = true; // maybe only when GVR SDK is present?
#elif UNITY_2017_2_OR_NEWER
            extension.present = XRDevice.isPresent;
#else
            extension.present = VRDevice.isPresent;
#endif

            Camera camera = CheckCamera();
            if (camera != null)
            {
                cameraTransform = camera.transform;
                neck2eyes       = HeadUtils.GetNeckEyeDelta(ivr);

                DeterminePlatform();

                if (vrTracking)
                {
                    if (!originOnFloor)
                    {
                        cameraRoot.transform.position = transform.position;
                        extension.trackerPosition     = cameraRoot.transform.localPosition;
                    }
                    cameraRoot.transform.rotation = ivr.transform.rotation;

                    cameraTransform.SetParent(cameraRoot.transform, false);
                }

                base.StartController(ivr);

#if INSTANTVR_ADVANCED
#if IVR_KINECT
                kinect2Head = GetComponent <IVR_Kinect2Head>();
#endif
#endif
            }
        }
예제 #3
0
        public override void StartController(InstantVR ivr)
        {
            if (extension == null)
            {
                extension = ivr.GetComponent <IVR_UnityVR>();
            }

            if (VRSettings.enabled)
            {
                extension.present = VRDevice.isPresent;

                Camera camera = CheckCamera();
                if (camera != null)
                {
                    cameraTransform = camera.transform;
                    neck2eyes       = HeadUtils.GetNeckEyeDelta(ivr);
                    head2eyes       = HeadUtils.GetHeadEyeDelta(ivr);

                    DeterminePlatform();

                    cameraRoot = new GameObject("UnityVR Root");
                    cameraRoot.transform.parent = ivr.transform;
#if UNITY_STANDALONE_WIN
                    if (needsOVR || needsSteamVR)
                    {
                        cameraRoot.transform.position = ivr.transform.position;
                    }
                    else
#endif
                    cameraRoot.transform.position = transform.position;

                    cameraRoot.transform.rotation = ivr.transform.rotation;

                    cameraTransform.SetParent(cameraRoot.transform, false);

                    base.StartController(ivr);

                    if (needsOVR)
                    {
                        ovrManager = transform.gameObject.AddComponent <OVRManager>();
                        if (ovrManager != null)
                        {
                            ovrManager.resetTrackerOnLoad = true;
#if UNITY_STANDALONE_WIN
                            ovrManager.trackingOriginType = OVRManager.TrackingOrigin.FloorLevel;
                            cameraTransform.localPosition = Vector3.zero;
#else
                            ovrManager.trackingOriginType = OVRManager.TrackingOrigin.EyeLevel;
#endif
                        }
                    }

                    if (needsSteamVR)
                    {
                        cameraTransform.gameObject.AddComponent <SteamVR_Camera>();
                        steamManager = cameraRoot.gameObject.AddComponent <SteamVR_ControllerManager>();
                    }

#if INSTANTVR_ADVANCED
                    kinect2Head = GetComponent <IVR_Kinect2Head>();
                    vicoVRHead  = GetComponent <IVR_VicoVRHead>();
#endif
                }
            }
        }