/// <summary> /// Installs the provided <see cref="MixedRealityServiceConfiguration"/> in the provided <see cref="MixedRealityToolkitRootProfile"/>. /// </summary> /// <param name="platformConfigurationProfile">The platform configuration to install.</param> /// <param name="rootProfile">The root profile to install the </param> public static void InstallConfiguration(MixedRealityPlatformServiceConfigurationProfile platformConfigurationProfile, MixedRealityToolkitRootProfile rootProfile) { foreach (var configuration in platformConfigurationProfile.Configurations) { var configurationType = configuration.InstancedType.Type; if (configurationType == null) { Debug.LogError($"Failed to find a valid {nameof(configuration.InstancedType)} for {configuration.Name}!"); continue; } switch (configurationType) { case Type _ when typeof(IMixedRealityCameraDataProvider).IsAssignableFrom(configurationType): var cameraSystemProfile = rootProfile.CameraSystemProfile; var cameraDataProviderConfiguration = new MixedRealityServiceConfiguration <IMixedRealityCameraDataProvider>(configuration); if (cameraSystemProfile.RegisteredServiceConfigurations.All(serviceConfiguration => serviceConfiguration.InstancedType.Type != cameraDataProviderConfiguration.InstancedType.Type)) { Debug.Log($"Added {configuration.Name} to {rootProfile.name}"); cameraSystemProfile.RegisteredServiceConfigurations = cameraSystemProfile.RegisteredServiceConfigurations.AddItem(cameraDataProviderConfiguration); EditorUtility.SetDirty(cameraSystemProfile); } break; case Type _ when typeof(IMixedRealityInputDataProvider).IsAssignableFrom(configurationType): var inputSystemProfile = rootProfile.InputSystemProfile; var inputDataProviderConfiguration = new MixedRealityServiceConfiguration <IMixedRealityInputDataProvider>(configuration); if (inputSystemProfile.RegisteredServiceConfigurations.All(serviceConfiguration => serviceConfiguration.InstancedType.Type != inputDataProviderConfiguration.InstancedType.Type)) { Debug.Log($"Added {configuration.Name} to {rootProfile.name}"); inputSystemProfile.RegisteredServiceConfigurations = inputSystemProfile.RegisteredServiceConfigurations.AddItem(inputDataProviderConfiguration); EditorUtility.SetDirty(inputSystemProfile); } break; case Type _ when typeof(IMixedRealitySpatialAwarenessDataProvider).IsAssignableFrom(configurationType): var spatialAwarenessSystemProfile = rootProfile.SpatialAwarenessProfile; var spatialObserverConfiguration = new MixedRealityServiceConfiguration <IMixedRealitySpatialAwarenessDataProvider>(configuration); if (spatialAwarenessSystemProfile.RegisteredServiceConfigurations.All(serviceConfiguration => serviceConfiguration.InstancedType.Type != spatialObserverConfiguration.InstancedType.Type)) { Debug.Log($"Added {configuration.Name} to {rootProfile.name}"); spatialAwarenessSystemProfile.RegisteredServiceConfigurations = spatialAwarenessSystemProfile.RegisteredServiceConfigurations.AddItem(spatialObserverConfiguration); EditorUtility.SetDirty(spatialAwarenessSystemProfile); } break; } } AssetDatabase.SaveAssets(); EditorApplication.delayCall += () => AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); }
protected override void OnEnable() { base.OnEnable(); headerStyle = null; rootProfile = target as MixedRealityToolkitRootProfile; var prefabStage = PrefabStageUtility.GetCurrentPrefabStage(); // Create the MixedRealityToolkit object if none exists. if (!MixedRealityToolkit.IsInitialized && prefabStage == null && !didPromptToConfigure) { // Search for all instances, in case we've just hot reloaded the assembly. var managerSearch = FindObjectsOfType <MixedRealityToolkit>(); if (managerSearch.Length == 0) { if (!ValidateImplementationsExists()) { if (EditorUtility.DisplayDialog( "Attention!", $"We were unable to find any services or data providers to configure. Would you like to install the {nameof(MixedRealityToolkit)} SDK?", "Yes", "Later", DialogOptOutDecisionType.ForThisSession, "XRTK_Prompt_Install_SDK")) { EditorApplication.delayCall += () => { Client.Add("com.xrtk.sdk"); }; } Selection.activeObject = null; return; } if (EditorUtility.DisplayDialog( "Attention!", "There is no active Mixed Reality Toolkit in your scene!\n\nWould you like to create one now?", "Yes", "Later", DialogOptOutDecisionType.ForThisSession, "XRTK_Prompt_Configure_Scene")) { if (MixedRealityToolkit.CameraSystem != null) { var playspace = MixedRealityToolkit.CameraSystem.MainCameraRig.PlayspaceTransform; Debug.Assert(playspace != null); } MixedRealityToolkit.Instance.ActiveProfile = rootProfile; } else { Debug.LogWarning("No Mixed Reality Toolkit in your scene."); didPromptToConfigure = true; } } } // Camera system configuration enableCameraSystem = serializedObject.FindProperty(nameof(enableCameraSystem)); cameraSystemType = serializedObject.FindProperty(nameof(cameraSystemType)); cameraSystemProfile = serializedObject.FindProperty(nameof(cameraSystemProfile)); // Input system configuration enableInputSystem = serializedObject.FindProperty(nameof(enableInputSystem)); inputSystemType = serializedObject.FindProperty(nameof(inputSystemType)); inputSystemProfile = serializedObject.FindProperty(nameof(inputSystemProfile)); // Boundary system configuration enableBoundarySystem = serializedObject.FindProperty(nameof(enableBoundarySystem)); boundarySystemType = serializedObject.FindProperty(nameof(boundarySystemType)); boundarySystemProfile = serializedObject.FindProperty(nameof(boundarySystemProfile)); // Teleport system configuration enableTeleportSystem = serializedObject.FindProperty(nameof(enableTeleportSystem)); teleportSystemType = serializedObject.FindProperty(nameof(teleportSystemType)); teleportSystemProfile = serializedObject.FindProperty(nameof(teleportSystemProfile)); // Spatial Awareness system configuration enableSpatialAwarenessSystem = serializedObject.FindProperty(nameof(enableSpatialAwarenessSystem)); spatialAwarenessSystemType = serializedObject.FindProperty(nameof(spatialAwarenessSystemType)); spatialAwarenessProfile = serializedObject.FindProperty(nameof(spatialAwarenessProfile)); // Networking system configuration enableNetworkingSystem = serializedObject.FindProperty(nameof(enableNetworkingSystem)); networkingSystemType = serializedObject.FindProperty(nameof(networkingSystemType)); networkingSystemProfile = serializedObject.FindProperty(nameof(networkingSystemProfile)); // Diagnostics system configuration enableDiagnosticsSystem = serializedObject.FindProperty(nameof(enableDiagnosticsSystem)); diagnosticsSystemType = serializedObject.FindProperty(nameof(diagnosticsSystemType)); diagnosticsSystemProfile = serializedObject.FindProperty(nameof(diagnosticsSystemProfile)); // Additional registered components configuration registeredServiceProvidersProfile = serializedObject.FindProperty(nameof(registeredServiceProvidersProfile)); }
protected override void OnEnable() { base.OnEnable(); rootProfile = target as MixedRealityToolkitRootProfile; 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 = rootProfile; } else { Debug.LogWarning("No Mixed Reality Toolkit in your scene."); } } } // Camera system configuration enableCameraSystem = serializedObject.FindProperty(nameof(enableCameraSystem)); cameraSystemType = serializedObject.FindProperty(nameof(cameraSystemType)); cameraProfile = serializedObject.FindProperty(nameof(cameraProfile)); // Input system configuration enableInputSystem = serializedObject.FindProperty(nameof(enableInputSystem)); inputSystemType = serializedObject.FindProperty(nameof(inputSystemType)); inputSystemProfile = serializedObject.FindProperty(nameof(inputSystemProfile)); // Boundary system configuration enableBoundarySystem = serializedObject.FindProperty(nameof(enableBoundarySystem)); boundarySystemType = serializedObject.FindProperty(nameof(boundarySystemType)); boundaryVisualizationProfile = serializedObject.FindProperty(nameof(boundaryVisualizationProfile)); // Teleport system configuration enableTeleportSystem = serializedObject.FindProperty(nameof(enableTeleportSystem)); teleportSystemType = serializedObject.FindProperty(nameof(teleportSystemType)); // Spatial Awareness system configuration enableSpatialAwarenessSystem = serializedObject.FindProperty(nameof(enableSpatialAwarenessSystem)); spatialAwarenessSystemType = serializedObject.FindProperty(nameof(spatialAwarenessSystemType)); spatialAwarenessProfile = serializedObject.FindProperty(nameof(spatialAwarenessProfile)); // Networking system configuration enableNetworkingSystem = serializedObject.FindProperty(nameof(enableNetworkingSystem)); networkingSystemType = serializedObject.FindProperty(nameof(networkingSystemType)); networkingSystemProfile = serializedObject.FindProperty(nameof(networkingSystemProfile)); // Diagnostics system configuration enableDiagnosticsSystem = serializedObject.FindProperty(nameof(enableDiagnosticsSystem)); diagnosticsSystemType = serializedObject.FindProperty(nameof(diagnosticsSystemType)); diagnosticsSystemProfile = serializedObject.FindProperty(nameof(diagnosticsSystemProfile)); // Additional registered components configuration registeredServiceProvidersProfile = serializedObject.FindProperty(nameof(registeredServiceProvidersProfile)); }