Exemple #1
0
 protected virtual void SwitchToSystem(XRSystem system)
 {
     OnSystemSwitch(system);
     if (OnSystemSwitched != null)
     {
         OnSystemSwitched(system);
     }
 }
Exemple #2
0
        protected override void OnSystemSwitch(XRSystem system)
        {
            XRControllerModule module = GetComponent <XRControllerModule>();

            if (module)
            {
                module.System = system;
            }
        }
        public void SetUp()
        {
            xrSystem = new XRSystem();
            cameras  = new Camera[k_CameraCount];
            for (int cameraIndex = 0; cameraIndex < k_CameraCount; ++cameraIndex)
            {
                var cameraGameObject = new GameObject();
                cameras[cameraIndex] = cameraGameObject.AddComponent <Camera>();
            }

            SimulateOneFrame();
        }
Exemple #4
0
        protected override void OnSystemSwitch(XRSystem system)
        {
            XRControllerModule module = GetComponent <XRControllerModule>();

            if (module)
            {
                module.System = system;

                //if GVR/Go, disable all modules that don't track this hand
                if (System == XRSystem.GearVROculusGo && Controllers.Count > 1)
                {
                    GVRVerifyController(module);
                }
            }
        }
Exemple #5
0
        private void SwitchActiveBuildTarget(XRSystem system)
        {
            switch (system)
            {
            case XRSystem.Standalone:
            case XRSystem.CV1:
            case XRSystem.Vive:
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
                break;

            case XRSystem.WindowsMR:
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WSA, BuildTarget.WSAPlayer);
                break;

            case XRSystem.GearVR:
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
                break;
            }
        }
Exemple #6
0
        public override void OnInspectorGUI()
        {
            UpdateXRAxes();

            GUILayout.Space(5);
            XRManager script       = (XRManager)target;
            XRSystem  system       = (XRSystem)EditorGUILayout.EnumPopup("System: ", script.System);
            bool      switchTarget = EditorGUILayout.ToggleLeft("Switch Build Target On Change", script.switchBuildTargetOnChange);

            script.switchBuildTargetOnChange = switchTarget;

            if (script.System != system)
            {
                if (EditorApplication.isPlaying)
                {
                    Debug.LogError("Cannot switch systems during Play Mode.");
                    return;
                }
                Undo.RecordObject(script, "Set Value");

                script.SwitchToSystem(system);
                bool vrs = system == XRSystem.Standalone ? false : true;

                PlayerSettings.virtualRealitySupported = vrs;

                if (switchTarget)
                {
                    SwitchActiveBuildTarget(script.System);
                }
            }

            GUILayout.Space(5);
            EditorGUILayout.LabelField("Supported External SDKS:", EditorStyles.boldLabel);
            for (int i = 0; i < script.AllSDKs.Count; i++)
            {
                script.EnabledSDKs[i] = EditorGUILayout.ToggleLeft(script.SDKNames[i], script.EnabledSDKs[i]);
            }

            UpdateScriptingDefineSymbols(script);

            EditorUtility.SetDirty(script);
        }
Exemple #7
0
        protected override void OnSystemSwitch(XRSystem system)
        {
            if (system == XRSystem.Standalone && standaloneCameraGoal)
            {
                this.transform.localPosition = standaloneCameraGoal.localPosition;
                this.transform.localRotation = standaloneCameraGoal.localRotation;
            }
            else if (System == XRSystem.GearVR && gearVRCameraGoal)
            {
                this.transform.localPosition = gearVRCameraGoal.localPosition;
                this.transform.localRotation = gearVRCameraGoal.localRotation;
            }
            else
            {
                this.transform.localPosition = Vector3.zero;
                this.transform.localRotation = Quaternion.identity;
            }

            //if (sensorFusion = GetComponent<XRSensorFusion>())
            //  sensorFusion.enabled = system == XRSystem.GearVR;
            if (mouseLook = GetComponent <XRMouseLook>())
            {
                mouseLook.enabled = system == XRSystem.Standalone;
            }
#if WAVE
            WaveVR_Render waveRender = GetComponentInChildren <WaveVR_Render>();
            if (waveRender)
            {
                waveRender.enabled = system == XRSystem.ViveFocus;
            }
            WaveVR_DevicePoseTracker waveTracker = GetComponentInChildren <WaveVR_DevicePoseTracker>();
            if (waveTracker)
            {
                waveTracker.enabled = system == XRSystem.ViveFocus;
            }
#endif
        }
 public void TearDown()
 {
     xrSystem = null;
     cameras  = null;
 }
Exemple #9
0
        public void SwitchToSystem(XRSystem system)
        {
#if OVR
            OVRManager ovr;
            if (!(ovr = GetComponent <OVRManager>()))
            {
                Debug.Log("Adding OVRManager to XRManager gameObject.");
                ovr = this.gameObject.AddComponent <OVRManager>();
                ovr.trackingOriginType = OVRManager.TrackingOrigin.FloorLevel;
            }
            ovr.enabled = (system == XRSystem.CV1 || system == XRSystem.GearVR);
#else
            if (system == XRSystem.CV1 || system == XRSystem.GearVR)
            {
                Debug.LogError("Cannot switch to " + system + " without OVR SDK!");
                return;
            }
#endif

#if DAYDREAM
            GvrControllerInput controller;
            if (!(controller = GetComponent <GvrControllerInput>()))
            {
                Debug.Log("Adding GvrControllerInput component to XRManager gameObject.");
                controller = gameObject.AddComponent <GvrControllerInput>();
            }
            controller.enabled = system == XRSystem.Daydream;

            GvrHeadset headset;
            if (!(headset = GetComponent <GvrHeadset>()))
            {
                Debug.Log("Adding GvrHeadset component to XRManager gameObject.");
                headset = gameObject.AddComponent <GvrHeadset>();
            }
            headset.enabled = system == XRSystem.Daydream;
#else
            if (system == XRSystem.Daydream)
            {
                Debug.LogError("Cannot switch to " + system + " without Daydream SDK!");
                return;
            }
#endif

#if WAVE
            Camera cam = GetComponentInChildren <Camera>();

            WaveVR_Render render;
            if (!(render = cam.GetComponent <WaveVR_Render>()))
            {
                Debug.Log("Adding WaveVR_Render to Main Camera gameObject.");
                render        = cam.gameObject.AddComponent <WaveVR_Render>();
                render.origin = wvr.WVR_PoseOriginModel.WVR_PoseOriginModel_OriginOnGround;
            }
            render.enabled = system == XRSystem.ViveFocus;

            WaveVR_DevicePoseTracker tracker;
            if (!(tracker = cam.GetComponent <WaveVR_DevicePoseTracker>()))
            {
                Debug.Log("Adding WaveVR_DevicePoseTracker to Main Camera gameObject.");
                tracker               = cam.gameObject.AddComponent <WaveVR_DevicePoseTracker>();
                tracker.type          = wvr.WVR_DeviceType.WVR_DeviceType_HMD;
                tracker.trackPosition = true;
                tracker.trackRotation = true;
                tracker.timing        = WaveVR_DevicePoseTracker.TrackingEvent.WhenNewPoses;
            }
            tracker.enabled = system == XRSystem.ViveFocus;
#else
            if (system == XRSystem.ViveFocus)
            {
                Debug.LogError("Cannot switch to " + system + " without Wave SDK!");
                return;
            }
#endif


            XRDevice[] devices = GetComponentsInChildren <XRDevice>();
            foreach (XRDevice device in devices)
            {
                device.System = system;
            }
            _system = system;
            Debug.Log("Switched to " + system);
        }
Exemple #10
0
 protected abstract void OnSystemSwitch(XRSystem system);