private void OnGUI()
            {
                EditorGUILayout.HelpBox("There is no active Mixed Reality Toolkit in your scene. Would you like to create one now?", MessageType.Warning);

                hideWarning = EditorGUILayout.Toggle("Don't show this again", hideWarning);

                configurationProfile = (MixedRealityToolkitConfigurationProfile)EditorGUILayout.ObjectField(configurationProfile, typeof(MixedRealityToolkitConfigurationProfile), false);
                if (configurationProfile == null)
                {
                    EditorGUILayout.HelpBox("Select a configuration profile.", MessageType.Info);
                }

                EditorGUILayout.BeginHorizontal();
                GUI.enabled = (configurationProfile != null);
                if (GUILayout.Button("Yes"))
                {
                    var playspace = MixedRealityToolkit.Instance.MixedRealityPlayspace;
                    Debug.Assert(playspace != null);
                    MixedRealityToolkit.Instance.ActiveProfile = configurationProfile;

                    SessionState.SetBool(HideNoActiveToolkitWarningKey, hideWarning);
                    Close();
                }
                GUI.enabled = true;

                if (GUILayout.Button("No"))
                {
                    SessionState.SetBool(HideNoActiveToolkitWarningKey, hideWarning);
                    Close();
                }
                EditorGUILayout.EndHorizontal();
            }
        public IEnumerator VerifyServiceCount()
        {
            MixedRealityToolkitConfigurationProfile profile1 = LoadTestProfile(BoundaryOnlyProfilePath);

            yield return(null);

            // Initialize the test case with profile 1
            InitializeTest(profile1);

            // Get count of registered services
            IReadOnlyList <IMixedRealityService> services = MixedRealityServiceRegistry.GetAllServices();
            int count1 = services.Count;

            yield return(null);

            // Switch to profile 2
            MixedRealityToolkitConfigurationProfile profile2 = LoadTestProfile(DefaultHoloLens2ProfilePath);

            ChangeProfile(profile2);
            yield return(null);

            // Get count of registered services
            services = MixedRealityServiceRegistry.GetAllServices();
            int count2 = services.Count;

            // We specifically selected the test profiles to ensure that they load a different number of services.
            Assert.IsTrue(count1 != count2);
        }
        private void ChangeProfile(MixedRealityToolkitConfigurationProfile newProfile)
        {
            MixedRealityToolkitConfigurationProfile oldProfile = MixedRealityToolkit.Instance.ActiveProfile;

            Debug.Log($"Switching active profile from {oldProfile.name} to {newProfile.name}");
            MixedRealityToolkit.Instance.ActiveProfile = newProfile;
        }
        public static void InitializeMixedRealityToolkit(MixedRealityToolkitConfigurationProfile configuration)
        {
            InitializeCamera();

            if (!MixedRealityToolkit.IsInitialized)
            {
                MixedRealityToolkit mixedRealityToolkit = new GameObject("MixedRealityToolkit").AddComponent <MixedRealityToolkit>();
                MixedRealityToolkit.SetActiveInstance(mixedRealityToolkit);
                MixedRealityToolkit.ConfirmInitialized();
            }

            // Todo: this condition shouldn't be here.
            // It's here due to some edit mode tests initializing MRTK instance in Edit mode, causing some of
            // event handler registration to live over tests and cause next tests to fail.
            // Exact reason requires investigation.
            if (Application.isPlaying)
            {
                BaseEventSystem.enableDanglingHandlerDiagnostics = true;
            }

            Debug.Assert(MixedRealityToolkit.IsInitialized);
            Debug.Assert(MixedRealityToolkit.Instance != null);


            MixedRealityToolkit.Instance.ActiveProfile = configuration;
            Debug.Assert(MixedRealityToolkit.Instance.ActiveProfile != null);
        }
        public static void InitializeMixedRealityToolkit(MixedRealityToolkitConfigurationProfile configuration)
        {
            InitializeCamera();

            // Ensure the AsyncCoroutineRunner is added to avoid log spam in the tests
            if (Object.FindObjectOfType <AsyncCoroutineRunner>() == null)
            {
                new GameObject("AsyncCoroutineRunner").AddComponent <AsyncCoroutineRunner>();
            }

#if UNITY_EDITOR
            MixedRealityInspectorUtility.AddMixedRealityToolkitToScene(configuration, true);
#endif

            // Todo: this condition shouldn't be here.
            // It's here due to some edit mode tests initializing MRTK instance in Edit mode, causing some of
            // event handler registration to live over tests and cause next tests to fail.
            // Exact reason requires investigation.
            if (Application.isPlaying)
            {
                BaseEventSystem.enableDanglingHandlerDiagnostics = true;
            }

            Debug.Assert(MixedRealityToolkit.IsInitialized);
            Debug.Assert(MixedRealityToolkit.Instance != null);

            Debug.Assert(MixedRealityToolkit.Instance.ActiveProfile != null);
        }
        /// <summary>
        /// If MRTK is not initialized in scene, adds and initializes instance to current scene
        /// </summary>
        public static void AddMixedRealityToolkitToScene(MixedRealityToolkitConfigurationProfile configProfile = null, bool inPlayMode = false)
        {
            if (!MixedRealityToolkit.IsInitialized)
            {
                MixedRealityToolkit newInstance = new GameObject("MixedRealityToolkit").AddComponent<MixedRealityToolkit>();
                MixedRealityToolkit.SetActiveInstance(newInstance);
                Selection.activeObject = newInstance;

                MixedRealityToolkit.ConfirmInitialized();

                if (configProfile == null)
                {
                    // if we don't have a profile set we get the default profile
                    newInstance.ActiveProfile = GetDefaultConfigProfile();
                }
                else
                {
                    newInstance.ActiveProfile = configProfile;
                }

                if(!newInstance.ActiveProfile.ExperienceSettingsProfile.IsNull())
                {
                    // Add a MixedRealitySceneContent object to a scene. Children of this object will scale appropriately dependent on MR platform
                    MixedRealitySceneContent contentAdjuster = new GameObject("MixedRealitySceneContent").AddComponent<MixedRealitySceneContent>();
                }

                if (!inPlayMode)
                {
                    EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                }
            }
        }
 private void Update()
 {
     if ((configProfile != null) && (MixedRealityToolkit.Instance != null))
     {
         MixedRealityToolkit.Instance.ActiveProfile = configProfile;
         Debug.Log($"Loading new MRTK configuration profile: {configProfile.name}");
         configProfile = null;
     }
 }
Example #8
0
        /// <summary>
        /// If MRTK is not initialized in scene, adds and initializes instance to current scene
        /// </summary>
        public static void AddMixedRealityToolkitToScene(MixedRealityToolkitConfigurationProfile configProfile = null)
        {
            if (!MixedRealityToolkit.IsInitialized)
            {
                MixedRealityToolkit newInstance = new GameObject("MixedRealityToolkit").AddComponent <MixedRealityToolkit>();
                MixedRealityToolkit.SetActiveInstance(newInstance);
                Selection.activeObject = newInstance;

                if (configProfile != null)
                {
                    newInstance.ActiveProfile = configProfile;
                }
            }
        }
        public IEnumerator VerifyPlayspaceChildren()
        {
            MixedRealityToolkitConfigurationProfile profile1 = TestUtilities.GetDefaultMixedRealityProfile <MixedRealityToolkitConfigurationProfile>();

            yield return(null);

            // Initialize the test case with profile 1
            InitializeTest(profile1);

            // Switch between the profiles a few times.
            MixedRealityToolkitConfigurationProfile profile2 = LoadTestProfile(DefaultHoloLens2ProfilePath);

            ChangeProfile(profile2);
            yield return(null);

            ChangeProfile(profile1);
            yield return(null);

            ChangeProfile(profile2);
            yield return(null);

            int uiRaycastCameraCount = 0;

            // Confirm that we have one UIRaycastCamera.
            Debug.Log("Validating UIRaycastCamera count.");
            Camera[] cameras = GameObject.FindObjectsOfType <Camera>();
            foreach (Camera camera in cameras)
            {
                if ("UIRaycastCamera" == camera.name)
                {
                    uiRaycastCameraCount++;
                }
            }
            Assert.AreEqual(1, uiRaycastCameraCount);

            // Confirm that we have only one instance of the default cursor.
            int defaultCursorCount = 0;

            Debug.Log("Validating DefaultCursor count.");
            foreach (Transform child in MixedRealityPlayspace.Transform.GetComponentsInChildren <Transform>())
            {
                if ("DefaultGazeCursor(Clone)" == child.name)
                {
                    defaultCursorCount++;
                }
            }
            Assert.AreEqual(1, defaultCursorCount);
        }
            public static void OpenWindow(MixedRealityToolkitConfigurationProfile configurationProfile)
            {
                // If we already have an active window, bail
                if (activeWindow != null)
                {
                    return;
                }

                activeWindow = EditorWindow.GetWindow <NoActiveToolkitWarning>();
                activeWindow.configurationProfile = configurationProfile;
                activeWindow.maxSize      = new Vector2(400, 140);
                activeWindow.minSize      = new Vector2(400, 140);
                activeWindow.titleContent = new GUIContent("No Active Toolkit Found");

                activeWindow.ShowPopup();
            }
Example #11
0
        /// <summary>
        /// When a configuration Profile is replaced with a new configuration, force all services to reset and read the new values
        /// </summary>
        /// <param name="profile"></param>
        public void ResetConfiguration(MixedRealityToolkitConfigurationProfile profile)
        {
            if (activeProfile != null)
            {
                DisableAllServices();
                DestroyAllServices();
            }

            activeProfile = profile;

            if (profile != null)
            {
                DisableAllServices();
                DestroyAllServices();
            }

            Initialize();
        }
Example #12
0
        /// <summary>
        /// If MRTK is not initialized in scene, adds and initializes instance to current scene
        /// </summary>
        public static void AddMixedRealityToolkitToScene(MixedRealityToolkitConfigurationProfile configProfile = null)
        {
            if (!MixedRealityToolkit.IsInitialized)
            {
                MixedRealityToolkit newInstance = new GameObject("MixedRealityToolkit").AddComponent <MixedRealityToolkit>();
                MixedRealityToolkit.SetActiveInstance(newInstance);
                Selection.activeObject = newInstance;

                if (configProfile == null)
                {
                    // if we don't have a profile set we get the default profile
                    newInstance.ActiveProfile = GetDefaultConfigProfile();
                }
                else
                {
                    newInstance.ActiveProfile = configProfile;
                }
            }
        }
Example #13
0
        /// <summary>
        /// Creates a play mode test scene, creates an MRTK instance, initializes playspace.
        /// </summary>
        /// <remarks>
        /// Takes an optional MixedRealityToolkitConfigurationProfile used to initialize the MRTK.
        /// </remarks>
        public static void Setup(MixedRealityToolkitConfigurationProfile profile = null)
        {
            Debug.Assert(Application.isPlaying, "This setup method should only be used during play mode tests. Use TestUtilities.");

            // See comments for UseSlowTestController for why this is reset to false on each test case.
            UseSlowTestController = false;

            bool sceneExists = false;

            for (int i = 0; i < SceneManager.sceneCount; i++)
            {
                Scene playModeTestScene = SceneManager.GetSceneAt(i);
                if (playModeTestScene.name == playModeTestSceneName && playModeTestScene.isLoaded)
                {
                    SceneManager.SetActiveScene(playModeTestScene);
                    sceneExists = true;
                }
            }

            if (!sceneExists)
            {
                Scene playModeTestScene = SceneManager.CreateScene(playModeTestSceneName);
                SceneManager.SetActiveScene(playModeTestScene);
            }

            // Create an MRTK instance and set up playspace
            if (profile == null)
            {
                TestUtilities.InitializeMixedRealityToolkit(true);
            }
            else
            {
                TestUtilities.InitializeMixedRealityToolkit(profile);
            }
            TestUtilities.InitializePlayspace();

            // Ensure user input is disabled during the tests
            InputSimulationService inputSimulationService = GetInputSimulationService();

            inputSimulationService.UserInputEnabled = false;
        }
        public static void InitializeMixedRealityToolkit(MixedRealityToolkitConfigurationProfile configuration)
        {
            InitializeCamera();
#if UNITY_EDITOR
            MixedRealityInspectorUtility.AddMixedRealityToolkitToScene(configuration, true);
#endif

            // Todo: this condition shouldn't be here.
            // It's here due to some edit mode tests initializing MRTK instance in Edit mode, causing some of
            // event handler registration to live over tests and cause next tests to fail.
            // Exact reason requires investigation.
            if (Application.isPlaying)
            {
                BaseEventSystem.enableDanglingHandlerDiagnostics = true;
            }

            Debug.Assert(MixedRealityToolkit.IsInitialized);
            Debug.Assert(MixedRealityToolkit.Instance != null);

            Debug.Assert(MixedRealityToolkit.Instance.ActiveProfile != null);
        }
        public IEnumerator VerifyServiceState()
        {
            MixedRealityToolkitConfigurationProfile profile1 = TestUtilities.GetDefaultMixedRealityProfile <MixedRealityToolkitConfigurationProfile>();

            yield return(null);

            // Initialize the test case with profile 1
            InitializeTest(profile1);

            // Cache the interesting settings read from the initial boundary system instance
            IMixedRealityBoundarySystem boundarySystem1 = CoreServices.BoundarySystem;

            yield return(null);

            float height1       = boundarySystem1.BoundaryHeight;
            int   floorPhysics1 = boundarySystem1.FloorPhysicsLayer;
            bool  showTracked1  = boundarySystem1.ShowTrackedArea;
            bool  showCeiling1  = boundarySystem1.ShowBoundaryCeiling;

            MixedRealityToolkitConfigurationProfile profile2 = LoadTestProfile(BoundaryOnlyProfilePath);

            // Switch to profile 2
            ChangeProfile(profile2);
            yield return(null);

            // The custom boundary profile has been configured to match the default with the following fields being different
            // * Boundary height
            // * Floor plane physics layer
            // * Show tracked area
            // * Show boundary ceiling
            IMixedRealityBoundarySystem boundarySystem2 = CoreServices.BoundarySystem;

            yield return(null);

            // Check service settings to ensure it has properly reset
            Assert.IsTrue(height1 != boundarySystem2.BoundaryHeight);
            Assert.IsTrue(floorPhysics1 != boundarySystem2.FloorPhysicsLayer);
            Assert.IsTrue(showTracked1 != boundarySystem2.ShowTrackedArea);
            Assert.IsTrue(showCeiling1 != boundarySystem2.ShowBoundaryCeiling);
        }
        protected override void OnEnable()
        {
            base.OnEnable();

            configurationProfile = target as MixedRealityToolkitConfigurationProfile;

            // Create The MR Manager if none exists.
            if (!MixedRealityToolkit.IsInitialized)
            {
                // Search the scene for one, in case we've just hot reloaded the assembly.
                var managerSearch = FindObjectsOfType <MixedRealityToolkit>();

                if (managerSearch.Length == 0)
                {
                    if (EditorUtility.DisplayDialog(
                            "Attention!",
                            "There is no active Mixed Reality Toolkit in your scene!\n\nWould you like to create one now?",
                            "Yes",
                            "Later"))
                    {
                        var playspace = MixedRealityToolkit.Instance.MixedRealityPlayspace;
                        Debug.Assert(playspace != null);
                        MixedRealityToolkit.Instance.ActiveProfile = configurationProfile;
                    }
                    else
                    {
                        Debug.LogWarning("No Mixed Reality Toolkit in your scene.");
                        return;
                    }
                }
            }

            if (!MixedRealityToolkit.ConfirmInitialized())
            {
                return;
            }

            if (!MixedRealityToolkit.HasActiveProfile)
            {
                return;
            }

            // Experience configuration
            targetExperienceScale = serializedObject.FindProperty("targetExperienceScale");
            // Camera configuration
            enableCameraProfile = serializedObject.FindProperty("enableCameraProfile");
            cameraProfile       = serializedObject.FindProperty("cameraProfile");
            // Input system configuration
            enableInputSystem  = serializedObject.FindProperty("enableInputSystem");
            inputSystemType    = serializedObject.FindProperty("inputSystemType");
            inputSystemProfile = serializedObject.FindProperty("inputSystemProfile");
            // Boundary system configuration
            enableBoundarySystem         = serializedObject.FindProperty("enableBoundarySystem");
            boundarySystemType           = serializedObject.FindProperty("boundarySystemType");
            boundaryVisualizationProfile = serializedObject.FindProperty("boundaryVisualizationProfile");
            // Teleport system configuration
            enableTeleportSystem = serializedObject.FindProperty("enableTeleportSystem");
            teleportSystemType   = serializedObject.FindProperty("teleportSystemType");
            // Spatial Awareness system configuration
            enableSpatialAwarenessSystem = serializedObject.FindProperty("enableSpatialAwarenessSystem");
            spatialAwarenessSystemType   = serializedObject.FindProperty("spatialAwarenessSystemType");
            spatialAwarenessProfile      = serializedObject.FindProperty("spatialAwarenessProfile");
            // Diagnostics system configuration
            enableDiagnosticsSystem  = serializedObject.FindProperty("enableDiagnosticsSystem");
            diagnosticsSystemType    = serializedObject.FindProperty("diagnosticsSystemType");
            diagnosticsSystemProfile = serializedObject.FindProperty("diagnosticsSystemProfile");

            // Additional registered components configuration
            registeredServiceProvidersProfile = serializedObject.FindProperty("registeredServiceProvidersProfile");
        }
 private void InitializeTest(MixedRealityToolkitConfigurationProfile profile)
 {
     TestUtilities.InitializeMixedRealityToolkit(profile);
     TestUtilities.PlayspaceToOriginLookingForward();
 }
        protected override void OnEnable()
        {
            base.OnEnable();

            if (target == null)
            {
                // Either when we are recompiling, or the inspector window is hidden behind another one, the target can get destroyed (null) and thereby will raise an ArgumentException when accessing serializedObject. For now, just return.
                return;
            }

            MixedRealityToolkitConfigurationProfile mrtkConfigProfile = target as MixedRealityToolkitConfigurationProfile;

            // Experience configuration
            targetExperienceScale = serializedObject.FindProperty("targetExperienceScale");
            // Camera configuration
            enableCameraSystem = serializedObject.FindProperty("enableCameraSystem");
            cameraSystemType   = serializedObject.FindProperty("cameraSystemType");
            cameraProfile      = serializedObject.FindProperty("cameraProfile");
            // Input system configuration
            enableInputSystem  = serializedObject.FindProperty("enableInputSystem");
            inputSystemType    = serializedObject.FindProperty("inputSystemType");
            inputSystemProfile = serializedObject.FindProperty("inputSystemProfile");
            // Boundary system configuration
            enableBoundarySystem         = serializedObject.FindProperty("enableBoundarySystem");
            boundarySystemType           = serializedObject.FindProperty("boundarySystemType");
            boundaryVisualizationProfile = serializedObject.FindProperty("boundaryVisualizationProfile");
            // Teleport system configuration
            enableTeleportSystem = serializedObject.FindProperty("enableTeleportSystem");
            teleportSystemType   = serializedObject.FindProperty("teleportSystemType");
            // Spatial Awareness system configuration
            enableSpatialAwarenessSystem  = serializedObject.FindProperty("enableSpatialAwarenessSystem");
            spatialAwarenessSystemType    = serializedObject.FindProperty("spatialAwarenessSystemType");
            spatialAwarenessSystemProfile = serializedObject.FindProperty("spatialAwarenessSystemProfile");
            // Diagnostics system configuration
            enableDiagnosticsSystem  = serializedObject.FindProperty("enableDiagnosticsSystem");
            diagnosticsSystemType    = serializedObject.FindProperty("diagnosticsSystemType");
            diagnosticsSystemProfile = serializedObject.FindProperty("diagnosticsSystemProfile");
            // Scene system configuration
            enableSceneSystem  = serializedObject.FindProperty("enableSceneSystem");
            sceneSystemType    = serializedObject.FindProperty("sceneSystemType");
            sceneSystemProfile = serializedObject.FindProperty("sceneSystemProfile");

            // Additional registered components configuration
            registeredServiceProvidersProfile = serializedObject.FindProperty("registeredServiceProvidersProfile");

            // Editor settings
            useServiceInspectors = serializedObject.FindProperty("useServiceInspectors");

            SelectedProfileTab = EditorPrefs.GetInt(SelectedTabPreferenceKey, SelectedProfileTab);

            if (this.RenderProfileFuncs == null)
            {
                this.RenderProfileFuncs = new Func <bool>[]
                {
                    () => {
                        // Note: cannot use mrtkConfigProfile.Is*SystemEnabled because property checks multiple parameters
                        CheckSystemConfiguration("Camera System", enableCameraSystem.boolValue,
                                                 mrtkConfigProfile.CameraSystemType,
                                                 mrtkConfigProfile.CameraProfile != null);

                        EditorGUILayout.PropertyField(enableCameraSystem);
                        EditorGUILayout.PropertyField(cameraSystemType);

                        return(RenderProfile(cameraProfile, typeof(MixedRealityCameraProfile), true, false));
                    },
                    () => {
                        // Note: cannot use mrtkConfigProfile.Is*SystemEnabled because property checks multiple parameters
                        CheckSystemConfiguration("Input System", enableInputSystem.boolValue,
                                                 mrtkConfigProfile.InputSystemType,
                                                 mrtkConfigProfile.InputSystemProfile != null);

                        EditorGUILayout.PropertyField(enableInputSystem);
                        EditorGUILayout.PropertyField(inputSystemType);
                        return(RenderProfile(inputSystemProfile, null, true, false, typeof(IMixedRealityInputSystem)));
                    },
                    () => {
                        // Note: cannot use mrtkConfigProfile.Is*SystemEnabled because property checks multiple parameters
                        CheckSystemConfiguration("Boundary System", enableBoundarySystem.boolValue,
                                                 mrtkConfigProfile.BoundarySystemSystemType,
                                                 mrtkConfigProfile.BoundaryVisualizationProfile != null);

                        var experienceScale = (ExperienceScale)targetExperienceScale.intValue;
                        if (experienceScale != ExperienceScale.Room)
                        {
                            // Alert the user if the experience scale does not support boundary features.
                            GUILayout.Space(6f);
                            EditorGUILayout.HelpBox("Boundaries are only supported in Room scale experiences.", MessageType.Warning);
                            GUILayout.Space(6f);
                        }
                        EditorGUILayout.PropertyField(enableBoundarySystem);
                        EditorGUILayout.PropertyField(boundarySystemType);
                        return(RenderProfile(boundaryVisualizationProfile, null, true, false, typeof(IMixedRealityBoundarySystem)));
                    },
                    () => {
                        // Note: cannot use mrtkConfigProfile.Is*SystemEnabled because property checks multiple parameters
                        // Teleport System does not have a profile scriptableobject so auto to true
                        CheckSystemConfiguration("Teleport System", enableTeleportSystem.boolValue,
                                                 mrtkConfigProfile.TeleportSystemSystemType,
                                                 true);

                        EditorGUILayout.PropertyField(enableTeleportSystem);
                        EditorGUILayout.PropertyField(teleportSystemType);
                        return(false);
                    },
                    () => {
                        // Note: cannot use mrtkConfigProfile.Is*SystemEnabled because property checks multiple parameters
                        CheckSystemConfiguration("Spatial Awareness System", enableSpatialAwarenessSystem.boolValue,
                                                 mrtkConfigProfile.SpatialAwarenessSystemSystemType,
                                                 mrtkConfigProfile.SpatialAwarenessSystemProfile != null);

                        EditorGUILayout.PropertyField(enableSpatialAwarenessSystem);
                        EditorGUILayout.PropertyField(spatialAwarenessSystemType);
                        EditorGUILayout.HelpBox("Spatial Awareness settings are configured per observer.", MessageType.Info);
                        return(RenderProfile(spatialAwarenessSystemProfile, null, true, false, typeof(IMixedRealitySpatialAwarenessSystem)));
                    },
                    () => {
                        // Note: cannot use mrtkConfigProfile.Is*SystemEnabled because property checks multiple parameters
                        CheckSystemConfiguration("Diagnostics System", enableDiagnosticsSystem.boolValue,
                                                 mrtkConfigProfile.DiagnosticsSystemSystemType,
                                                 mrtkConfigProfile.DiagnosticsSystemProfile != null);

                        EditorGUILayout.HelpBox("It is recommended to enable the Diagnostics system during development. Be sure to disable prior to building your shipping product.", MessageType.Warning);
                        EditorGUILayout.PropertyField(enableDiagnosticsSystem);
                        EditorGUILayout.PropertyField(diagnosticsSystemType);
                        return(RenderProfile(diagnosticsSystemProfile, typeof(MixedRealityDiagnosticsProfile)));
                    },
                    () => {
                        // Note: cannot use mrtkConfigProfile.Is*SystemEnabled because property checks multiple parameters
                        CheckSystemConfiguration("Scene System", enableSceneSystem.boolValue,
                                                 mrtkConfigProfile.SceneSystemSystemType,
                                                 mrtkConfigProfile.SceneSystemProfile != null);

                        EditorGUILayout.PropertyField(enableSceneSystem);
                        EditorGUILayout.PropertyField(sceneSystemType);
                        return(RenderProfile(sceneSystemProfile, typeof(MixedRealitySceneSystemProfile), true, true, typeof(IMixedRealitySceneSystem)));
                    },
                    () => {
                        return(RenderProfile(registeredServiceProvidersProfile, typeof(MixedRealityRegisteredServiceProvidersProfile), true, false));
                    },
                    () => {
                        EditorGUILayout.PropertyField(useServiceInspectors);
                        return(false);
                    },
                };
            }
        }
Example #19
0
        protected override void OnEnable()
        {
            base.OnEnable();

            if (target == null)
            {
                // Either when we are recompiling, or the inspector window is hidden behind another one, the target can get destroyed (null) and thereby will raise an ArgumentException when accessing serializedObject. For now, just return.
                return;
            }

            MixedRealityToolkitConfigurationProfile mrtkConfigProfile = target as MixedRealityToolkitConfigurationProfile;

            // Experience configuration
            targetExperienceScale = serializedObject.FindProperty("targetExperienceScale");
            // Camera configuration
            enableCameraSystem = serializedObject.FindProperty("enableCameraSystem");
            cameraSystemType   = serializedObject.FindProperty("cameraSystemType");
            cameraProfile      = serializedObject.FindProperty("cameraProfile");
            // Input system configuration
            enableInputSystem  = serializedObject.FindProperty("enableInputSystem");
            inputSystemType    = serializedObject.FindProperty("inputSystemType");
            inputSystemProfile = serializedObject.FindProperty("inputSystemProfile");
            // Boundary system configuration
            enableBoundarySystem         = serializedObject.FindProperty("enableBoundarySystem");
            boundarySystemType           = serializedObject.FindProperty("boundarySystemType");
            boundaryVisualizationProfile = serializedObject.FindProperty("boundaryVisualizationProfile");
            // Teleport system configuration
            enableTeleportSystem = serializedObject.FindProperty("enableTeleportSystem");
            teleportSystemType   = serializedObject.FindProperty("teleportSystemType");
            // Spatial Awareness system configuration
            enableSpatialAwarenessSystem  = serializedObject.FindProperty("enableSpatialAwarenessSystem");
            spatialAwarenessSystemType    = serializedObject.FindProperty("spatialAwarenessSystemType");
            spatialAwarenessSystemProfile = serializedObject.FindProperty("spatialAwarenessSystemProfile");
            // Diagnostics system configuration
            enableDiagnosticsSystem  = serializedObject.FindProperty("enableDiagnosticsSystem");
            enableVerboseLogging     = serializedObject.FindProperty("enableVerboseLogging");
            diagnosticsSystemType    = serializedObject.FindProperty("diagnosticsSystemType");
            diagnosticsSystemProfile = serializedObject.FindProperty("diagnosticsSystemProfile");
            // Scene system configuration
            enableSceneSystem  = serializedObject.FindProperty("enableSceneSystem");
            sceneSystemType    = serializedObject.FindProperty("sceneSystemType");
            sceneSystemProfile = serializedObject.FindProperty("sceneSystemProfile");

            // Additional registered components configuration
            registeredServiceProvidersProfile = serializedObject.FindProperty("registeredServiceProvidersProfile");

            // Editor settings
            useServiceInspectors = serializedObject.FindProperty("useServiceInspectors");
            renderDepthBuffer    = serializedObject.FindProperty("renderDepthBuffer");

            SelectedProfileTab = SessionState.GetInt(SelectedTabPreferenceKey, SelectedProfileTab);

            if (RenderProfileFuncs == null)
            {
                RenderProfileFuncs = new Func <bool>[]
                {
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableCameraSystem);

                            const string service = "Camera System";
                            if (enableCameraSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.CameraSystemType, mrtkConfigProfile.CameraProfile != null);

                                EditorGUILayout.PropertyField(cameraSystemType);

                                changed |= RenderProfile(cameraProfile, typeof(MixedRealityCameraProfile), true, false);
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableInputSystem);

                            const string service = "Input System";
                            if (enableInputSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.InputSystemType, mrtkConfigProfile.InputSystemProfile != null);

                                EditorGUILayout.PropertyField(inputSystemType);

                                changed |= RenderProfile(inputSystemProfile, null, true, false, typeof(IMixedRealityInputSystem));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        var experienceScale = (ExperienceScale)targetExperienceScale.intValue;
                        if (experienceScale != ExperienceScale.Room)
                        {
                            // Alert the user if the experience scale does not support boundary features.
                            GUILayout.Space(6f);
                            EditorGUILayout.HelpBox("Boundaries are only supported in Room scale experiences.", MessageType.Warning);
                            GUILayout.Space(6f);
                        }

                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableBoundarySystem);

                            const string service = "Boundary System";
                            if (enableBoundarySystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.BoundarySystemSystemType, mrtkConfigProfile.BoundaryVisualizationProfile != null);

                                EditorGUILayout.PropertyField(boundarySystemType);

                                changed |= RenderProfile(boundaryVisualizationProfile, null, true, false, typeof(IMixedRealityBoundarySystem));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        const string service = "Teleport System";
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableTeleportSystem);
                            if (enableTeleportSystem.boolValue)
                            {
                                // Teleport System does not have a profile scriptableobject so auto to true
                                CheckSystemConfiguration(service, mrtkConfigProfile.TeleportSystemSystemType, true);

                                EditorGUILayout.PropertyField(teleportSystemType);
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            return(c.changed);
                        }
                    },
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            const string service = "Spatial Awareness System";
                            EditorGUILayout.PropertyField(enableSpatialAwarenessSystem);

                            if (enableSpatialAwarenessSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.SpatialAwarenessSystemSystemType, mrtkConfigProfile.SpatialAwarenessSystemProfile != null);

                                EditorGUILayout.PropertyField(spatialAwarenessSystemType);

                                EditorGUILayout.HelpBox("Spatial Awareness settings are configured per observer.", MessageType.Info);

                                changed |= RenderProfile(spatialAwarenessSystemProfile, null, true, false, typeof(IMixedRealitySpatialAwarenessSystem));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        EditorGUILayout.HelpBox("It is recommended to enable the Diagnostics system during development. Be sure to disable prior to building your shipping product.", MessageType.Warning);

                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableVerboseLogging);
                            EditorGUILayout.PropertyField(enableDiagnosticsSystem);

                            const string service = "Diagnostics System";
                            if (enableDiagnosticsSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.DiagnosticsSystemSystemType, mrtkConfigProfile.DiagnosticsSystemProfile != null);

                                EditorGUILayout.PropertyField(diagnosticsSystemType);

                                changed |= RenderProfile(diagnosticsSystemProfile, typeof(MixedRealityDiagnosticsProfile));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableSceneSystem);
                            const string service = "Scene System";
                            if (enableSceneSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.SceneSystemSystemType, mrtkConfigProfile.SceneSystemProfile != null);

                                EditorGUILayout.PropertyField(sceneSystemType);

                                changed |= RenderProfile(sceneSystemProfile, typeof(MixedRealitySceneSystemProfile), true, true, typeof(IMixedRealitySceneSystem));
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        return(RenderProfile(registeredServiceProvidersProfile, typeof(MixedRealityRegisteredServiceProvidersProfile), true, false));
                    },
                    () => {
                        EditorGUILayout.PropertyField(useServiceInspectors);

                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(renderDepthBuffer);
                            if (c.changed)
                            {
                                if (renderDepthBuffer.boolValue)
                                {
                                    CameraCache.Main.gameObject.AddComponent <DepthBufferRenderer>();
                                }
                                else
                                {
                                    foreach (var dbr in FindObjectsOfType <DepthBufferRenderer>())
                                    {
                                        UnityObjectExtensions.DestroyObject(dbr);
                                    }
                                }
                            }
                        }
                        return(false);
                    },
                };
            }
        }
Example #20
0
        protected override void OnEnable()
        {
            base.OnEnable();

            if (target == null)
            {
                // Either when we are recompiling, or the inspector window is hidden behind another one, the target can get destroyed (null) and thereby will raise an ArgumentException when accessing serializedObject. For now, just return.
                return;
            }

            MixedRealityToolkitConfigurationProfile mrtkConfigProfile = target as MixedRealityToolkitConfigurationProfile;

            // Experience configuration
            experienceSettingsProfile = serializedObject.FindProperty("experienceSettingsProfile");
            experienceScaleMigration  = serializedObject.FindProperty("targetExperienceScale");

            // Camera configuration
            enableCameraSystem = serializedObject.FindProperty("enableCameraSystem");
            cameraSystemType   = serializedObject.FindProperty("cameraSystemType");
            cameraProfile      = serializedObject.FindProperty("cameraProfile");
            // Input system configuration
            enableInputSystem  = serializedObject.FindProperty("enableInputSystem");
            inputSystemType    = serializedObject.FindProperty("inputSystemType");
            inputSystemProfile = serializedObject.FindProperty("inputSystemProfile");
            // Boundary system configuration
            enableBoundarySystem         = serializedObject.FindProperty("enableBoundarySystem");
            boundarySystemType           = serializedObject.FindProperty("boundarySystemType");
            xrsdkBoundarySystemType      = serializedObject.FindProperty("xrsdkBoundarySystemType");
            boundaryVisualizationProfile = serializedObject.FindProperty("boundaryVisualizationProfile");
#if UNITY_2019
            xrPipelineUtility.Enable();
#endif // UNITY_2019

            // Teleport system configuration
            enableTeleportSystem = serializedObject.FindProperty("enableTeleportSystem");
            teleportSystemType   = serializedObject.FindProperty("teleportSystemType");
            // Spatial Awareness system configuration
            enableSpatialAwarenessSystem  = serializedObject.FindProperty("enableSpatialAwarenessSystem");
            spatialAwarenessSystemType    = serializedObject.FindProperty("spatialAwarenessSystemType");
            spatialAwarenessSystemProfile = serializedObject.FindProperty("spatialAwarenessSystemProfile");
            // Diagnostics system configuration
            enableDiagnosticsSystem  = serializedObject.FindProperty("enableDiagnosticsSystem");
            enableVerboseLogging     = serializedObject.FindProperty("enableVerboseLogging");
            diagnosticsSystemType    = serializedObject.FindProperty("diagnosticsSystemType");
            diagnosticsSystemProfile = serializedObject.FindProperty("diagnosticsSystemProfile");
            // Scene system configuration
            enableSceneSystem  = serializedObject.FindProperty("enableSceneSystem");
            sceneSystemType    = serializedObject.FindProperty("sceneSystemType");
            sceneSystemProfile = serializedObject.FindProperty("sceneSystemProfile");

            // Additional registered components configuration
            registeredServiceProvidersProfile = serializedObject.FindProperty("registeredServiceProvidersProfile");

            // Editor settings
            useServiceInspectors = serializedObject.FindProperty("useServiceInspectors");
            renderDepthBuffer    = serializedObject.FindProperty("renderDepthBuffer");

            SelectedProfileTab = SessionState.GetInt(SelectedTabPreferenceKey, SelectedProfileTab);

            if (renderProfileFuncs == null)
            {
                renderProfileFuncs = new Func <bool>[]
                {
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            // Reconciling old Experience Scale property with the Experience Settings Profile
                            var oldExperienceSettigsScale = (experienceSettingsProfile.objectReferenceValue as MixedRealityExperienceSettingsProfile)?.TargetExperienceScale;

                            changed |= RenderProfile(experienceSettingsProfile, typeof(MixedRealityExperienceSettingsProfile), true, false, null);

                            // Experience configuration
                            if (!mrtkConfigProfile.ExperienceSettingsProfile.IsNull())
                            {
                                // If the Experience Scale property changed, make sure we also alter the configuration profile's target experience scale property for compatibility
                                var newExperienceSettigs = (experienceSettingsProfile.objectReferenceValue as MixedRealityExperienceSettingsProfile)?.TargetExperienceScale;
                                if (oldExperienceSettigsScale.HasValue && newExperienceSettigs.HasValue && oldExperienceSettigsScale != newExperienceSettigs)
                                {
                                    experienceScaleMigration.intValue = (int)newExperienceSettigs;
                                    experienceScaleMigration.serializedObject.ApplyModifiedProperties();
                                }
                                // If we have not changed the Experience Settings profile and it's value is out of sync with the top level configuration profile, display a migration prompt
                                else if ((ExperienceScale)experienceScaleMigration.intValue != mrtkConfigProfile.ExperienceSettingsProfile.TargetExperienceScale)
                                {
                                    Color errorColor   = Color.Lerp(Color.white, Color.red, 0.5f);
                                    Color defaultColor = GUI.color;

                                    GUI.color = errorColor;
                                    EditorGUILayout.HelpBox("A previous version of this profile has a different Experience Scale, displayed below. Please modify the Experience Setting Profile's Target Experience Scale or select your desired scale below", MessageType.Warning);
                                    var oldValue = experienceScaleMigration.intValue;
                                    EditorGUILayout.PropertyField(experienceScaleMigration);
                                    if (oldValue != experienceScaleMigration.intValue)
                                    {
                                        mrtkConfigProfile.ExperienceSettingsProfile.TargetExperienceScale = (ExperienceScale)experienceScaleMigration.intValue;
                                    }
                                    GUI.color = defaultColor;
                                }


                                ExperienceScale experienceScale         = mrtkConfigProfile.ExperienceSettingsProfile.TargetExperienceScale;
                                string          targetExperienceSummary = GetExperienceDescription(experienceScale);
                                if (!string.IsNullOrEmpty(targetExperienceSummary))
                                {
                                    EditorGUILayout.HelpBox(targetExperienceSummary, MessageType.None);
                                    EditorGUILayout.Space();
                                }
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableCameraSystem);

                            const string service = "Camera System";
                            if (enableCameraSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.CameraSystemType, mrtkConfigProfile.CameraProfile != null);

                                EditorGUILayout.PropertyField(cameraSystemType);

                                changed |= RenderProfile(cameraProfile, typeof(MixedRealityCameraProfile), true, false);
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableInputSystem);

                            const string service = "Input System";
                            if (enableInputSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.InputSystemType, mrtkConfigProfile.InputSystemProfile != null);

                                EditorGUILayout.PropertyField(inputSystemType);

                                changed |= RenderProfile(inputSystemProfile, null, true, false, typeof(IMixedRealityInputSystem));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        if (mrtkConfigProfile.ExperienceSettingsProfile.IsNull())
                        {
                            // Alert that an experience settings profile has not been selected
                            GUILayout.Space(6f);
                            EditorGUILayout.HelpBox("Boundaries require an experience settings profile with a Room scale target experience scale.", MessageType.Warning);
                            GUILayout.Space(6f);
                        }
                        else
                        {
                            var experienceScale = mrtkConfigProfile.ExperienceSettingsProfile.TargetExperienceScale;
                            if (experienceScale != ExperienceScale.Room)
                            {
                                // Alert the user if the experience scale does not support boundary features.
                                GUILayout.Space(6f);
                                EditorGUILayout.HelpBox("Boundaries are only supported in Room scale experiences.", MessageType.Warning);
                                GUILayout.Space(6f);
                            }
                        }

                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableBoundarySystem);

                            const string service = "Boundary System";
                            if (enableBoundarySystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.BoundarySystemSystemType, mrtkConfigProfile.BoundaryVisualizationProfile != null);

#if UNITY_2019
                                xrPipelineUtility.RenderXRPipelineTabs();
#endif // UNITY_2019

                                EditorGUILayout.PropertyField(xrPipelineUtility.SelectedPipeline == SupportedUnityXRPipelines.XRSDK ? xrsdkBoundarySystemType : boundarySystemType);

                                changed |= RenderProfile(boundaryVisualizationProfile, null, true, false, typeof(IMixedRealityBoundarySystem));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        const string service = "Teleport System";
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableTeleportSystem);
                            if (enableTeleportSystem.boolValue)
                            {
                                // Teleport System does not have a profile scriptableobject so auto to true
                                CheckSystemConfiguration(service, mrtkConfigProfile.TeleportSystemSystemType, true);

                                EditorGUILayout.PropertyField(teleportSystemType);
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            return(c.changed);
                        }
                    },
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            const string service = "Spatial Awareness System";
                            EditorGUILayout.PropertyField(enableSpatialAwarenessSystem);

                            if (enableSpatialAwarenessSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.SpatialAwarenessSystemSystemType, mrtkConfigProfile.SpatialAwarenessSystemProfile != null);

                                EditorGUILayout.PropertyField(spatialAwarenessSystemType);

                                EditorGUILayout.HelpBox("Spatial Awareness settings are configured per observer.", MessageType.Info);

                                changed |= RenderProfile(spatialAwarenessSystemProfile, null, true, false, typeof(IMixedRealitySpatialAwarenessSystem));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        EditorGUILayout.HelpBox("It is recommended to enable the Diagnostics system during development. Be sure to disable prior to building your shipping product.", MessageType.Warning);

                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableVerboseLogging);
                            EditorGUILayout.PropertyField(enableDiagnosticsSystem);

                            const string service = "Diagnostics System";
                            if (enableDiagnosticsSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.DiagnosticsSystemSystemType, mrtkConfigProfile.DiagnosticsSystemProfile != null);

                                EditorGUILayout.PropertyField(diagnosticsSystemType);

                                changed |= RenderProfile(diagnosticsSystemProfile, typeof(MixedRealityDiagnosticsProfile));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableSceneSystem);
                            const string service = "Scene System";
                            if (enableSceneSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.SceneSystemSystemType, mrtkConfigProfile.SceneSystemProfile != null);

                                EditorGUILayout.PropertyField(sceneSystemType);

                                changed |= RenderProfile(sceneSystemProfile, typeof(MixedRealitySceneSystemProfile), true, true, typeof(IMixedRealitySceneSystem));
                            }
                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        return(RenderProfile(registeredServiceProvidersProfile, typeof(MixedRealityRegisteredServiceProvidersProfile), true, false));
                    },
                    () => {
                        EditorGUILayout.PropertyField(useServiceInspectors);

                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(renderDepthBuffer);
                            if (c.changed)
                            {
                                if (renderDepthBuffer.boolValue)
                                {
                                    CameraCache.Main.gameObject.AddComponent <DepthBufferRenderer>();
                                }
                                else
                                {
                                    foreach (var dbr in FindObjectsOfType <DepthBufferRenderer>())
                                    {
                                        UnityObjectExtensions.DestroyObject(dbr);
                                    }
                                }
                            }
                        }
                        return(false);
                    },
                };
            }
        }
Example #21
0
        protected override void OnEnable()
        {
            base.OnEnable();

            configurationProfile = target as MixedRealityToolkitConfigurationProfile;

            var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();

            // Create The MR Manager if none exists.
            if (!MixedRealityToolkit.IsInitialized && prefabStage == null)
            {
                // TODO Check base scene for service locator existence?

                // Search for all instances, in case we've just hot reloaded the assembly.
                var managerSearch = FindObjectsOfType <MixedRealityToolkit>();

                if (managerSearch.Length == 0)
                {
                    if (EditorUtility.DisplayDialog(
                            "Attention!",
                            "There is no active Mixed Reality Toolkit in your scene!\n\nWould you like to create one now?",
                            "Yes",
                            "Later"))
                    {
                        if (MixedRealityToolkit.CameraSystem != null)
                        {
                            var playspace = MixedRealityToolkit.CameraSystem.CameraRig.PlayspaceTransform;
                            Debug.Assert(playspace != null);
                        }

                        MixedRealityToolkit.Instance.ActiveProfile = configurationProfile;
                    }
                    else
                    {
                        Debug.LogWarning("No Mixed Reality Toolkit in your scene.");
                    }
                }
            }

            // Camera configuration
            enableCameraSystem = serializedObject.FindProperty("enableCameraSystem");
            cameraSystemType   = serializedObject.FindProperty("cameraSystemType");
            cameraProfile      = serializedObject.FindProperty("cameraProfile");
            // Input system configuration
            enableInputSystem  = serializedObject.FindProperty("enableInputSystem");
            inputSystemType    = serializedObject.FindProperty("inputSystemType");
            inputSystemProfile = serializedObject.FindProperty("inputSystemProfile");
            // Boundary system configuration
            enableBoundarySystem         = serializedObject.FindProperty("enableBoundarySystem");
            boundarySystemType           = serializedObject.FindProperty("boundarySystemType");
            boundaryVisualizationProfile = serializedObject.FindProperty("boundaryVisualizationProfile");
            // Teleport system configuration
            enableTeleportSystem = serializedObject.FindProperty("enableTeleportSystem");
            teleportSystemType   = serializedObject.FindProperty("teleportSystemType");
            // Spatial Awareness system configuration
            enableSpatialAwarenessSystem = serializedObject.FindProperty("enableSpatialAwarenessSystem");
            spatialAwarenessSystemType   = serializedObject.FindProperty("spatialAwarenessSystemType");
            spatialAwarenessProfile      = serializedObject.FindProperty("spatialAwarenessProfile");
            // Networking system configuration
            enableNetworkingSystem  = serializedObject.FindProperty("enableNetworkingSystem");
            networkingSystemType    = serializedObject.FindProperty("networkingSystemType");
            networkingSystemProfile = serializedObject.FindProperty("networkingSystemProfile");
            // Diagnostics system configuration
            enableDiagnosticsSystem  = serializedObject.FindProperty("enableDiagnosticsSystem");
            diagnosticsSystemType    = serializedObject.FindProperty("diagnosticsSystemType");
            diagnosticsSystemProfile = serializedObject.FindProperty("diagnosticsSystemProfile");

            // Additional registered components configuration
            registeredServiceProvidersProfile = serializedObject.FindProperty("registeredServiceProvidersProfile");
        }
Example #22
0
        protected override void OnEnable()
        {
            base.OnEnable();

            if (target == null)
            {
                // Either when we are recompiling, or the inspector window is hidden behind another one, the target can get destroyed (null) and thereby will raise an ArgumentException when accessing serializedObject. For now, just return.
                return;
            }

            configurationProfile = target as MixedRealityToolkitConfigurationProfile;

            // Create The MR Manager if none exists.
            if (!MixedRealityToolkit.IsInitialized)
            {
                // Search the scene for one, in case we've just hot reloaded the assembly.
                var managerSearch = FindObjectsOfType <MixedRealityToolkit>();

                if (managerSearch.Length == 0)
                {
                    HideNoActiveToolkitWarning = SessionState.GetBool(HideNoActiveToolkitWarningKey, false);
                    if (!HideNoActiveToolkitWarning)
                    {
                        NoActiveToolkitWarning.OpenWindow(configurationProfile);
                    }
                    return;
                }
            }

            if (!MixedRealityToolkit.ConfirmInitialized())
            {
                return;
            }

            if (!MixedRealityToolkit.Instance.HasActiveProfile)
            {
                return;
            }

            // Experience configuration
            targetExperienceScale = serializedObject.FindProperty("targetExperienceScale");
            // Camera configuration
            enableCameraProfile = serializedObject.FindProperty("enableCameraProfile");
            cameraProfile       = serializedObject.FindProperty("cameraProfile");
            // Input system configuration
            enableInputSystem  = serializedObject.FindProperty("enableInputSystem");
            inputSystemType    = serializedObject.FindProperty("inputSystemType");
            inputSystemProfile = serializedObject.FindProperty("inputSystemProfile");
            // Boundary system configuration
            enableBoundarySystem         = serializedObject.FindProperty("enableBoundarySystem");
            boundarySystemType           = serializedObject.FindProperty("boundarySystemType");
            boundaryVisualizationProfile = serializedObject.FindProperty("boundaryVisualizationProfile");
            // Teleport system configuration
            enableTeleportSystem = serializedObject.FindProperty("enableTeleportSystem");
            teleportSystemType   = serializedObject.FindProperty("teleportSystemType");
            // Spatial Awareness system configuration
            enableSpatialAwarenessSystem  = serializedObject.FindProperty("enableSpatialAwarenessSystem");
            spatialAwarenessSystemType    = serializedObject.FindProperty("spatialAwarenessSystemType");
            spatialAwarenessSystemProfile = serializedObject.FindProperty("spatialAwarenessSystemProfile");
            // Diagnostics system configuration
            enableDiagnosticsSystem  = serializedObject.FindProperty("enableDiagnosticsSystem");
            diagnosticsSystemType    = serializedObject.FindProperty("diagnosticsSystemType");
            diagnosticsSystemProfile = serializedObject.FindProperty("diagnosticsSystemProfile");

            // Additional registered components configuration
            registeredServiceProvidersProfile = serializedObject.FindProperty("registeredServiceProvidersProfile");
        }