/// <summary> /// Initialize the manager. /// </summary> private void InitializeManager() { #if UNITY_EDITOR // Make sure unity axis mappings are set. InputMappingAxisUtility.CheckUnityInputManagerMappings(ControllerMappingLibrary.UnityInputManagerAxes); #endif // The input system class takes arguments for: // * The input system profile object[] args = { profile }; Initialize <IMixedRealityInputSystem>(InputSystemType.Type, args: args); // The input system uses the focus provider specified in the profile. // The args for the focus provider are: // * The input system profile args = new object[] { profile }; Initialize <IMixedRealityFocusProvider>(profile.FocusProviderType.Type, args: args); // The input system uses the raycast provider specified in the profile. // The args for the focus provider are: // * The input system profile args = new object[] { profile }; Initialize <IMixedRealityRaycastProvider>(profile.RaycastProviderType, args: args); EventSystem[] eventSystems = FindObjectsOfType <EventSystem>(); if (eventSystems.Length == 0) { CameraCache.Main.gameObject.EnsureComponent <EventSystem>(); } }
public void TestRemoveCustomMappings() { InputMappingAxisUtility.RemoveMappings(ControllerMappingLibrary.UnityInputManagerAxes); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_1)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_2)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_4)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_5)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_9)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_10)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_11)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_12)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_13)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_14)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_15)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_16)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_17)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_18)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_19)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_20)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_21)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_22)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_23)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_24)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_25)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_26)); Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(ControllerMappingLibrary.AXIS_27)); }
/// <summary> /// Uninitialize the manager. /// </summary> private void UninitializeManager() { Uninitialize <IMixedRealityRaycastProvider>(); Uninitialize <IMixedRealityFocusProvider>(); Uninitialize <IMixedRealityInputSystem>(); #if UNITY_EDITOR InputMappingAxisUtility.RemoveMappings(ControllerMappingLibrary.UnityInputManagerAxes); #endif }
public void TearDown() { // Put the mappings back. InputMappingAxisUtility.CheckUnityInputManagerMappings(ControllerMappingLibrary.UnityInputManagerAxes); }
/// <summary> /// Once all services are registered and properties updated, the Mixed Reality Toolkit will initialize all active services. /// This ensures all services can reference each other once started. /// </summary> private void InitializeServiceLocator() { isInitializing = true; //If the Mixed Reality Toolkit is not configured, stop. if (ActiveProfile == null) { Debug.LogError("No Mixed Reality Configuration Profile found, cannot initialize the Mixed Reality Toolkit"); return; } #if UNITY_EDITOR if (ActiveSystems.Count > 0) { activeSystems.Clear(); } if (RegisteredMixedRealityServices.Count > 0) { registeredMixedRealityServices.Clear(); } #endif ClearCoreSystemCache(); EnsureMixedRealityRequirements(); #region Services Registration // If the Input system has been selected for initialization in the Active profile, enable it in the project if (ActiveProfile.IsInputSystemEnabled) { #if UNITY_EDITOR // Make sure unity axis mappings are set. InputMappingAxisUtility.CheckUnityInputManagerMappings(ControllerMappingLibrary.UnityInputManagerAxes); #endif object[] args = { this, ActiveProfile.InputSystemProfile }; if (!RegisterService <IMixedRealityInputSystem>(ActiveProfile.InputSystemType, args: args) || InputSystem == null) { Debug.LogError("Failed to start the Input System!"); } args = new object[] { this, InputSystem, ActiveProfile.InputSystemProfile }; if (!RegisterDataProvider <IMixedRealityFocusProvider>(ActiveProfile.InputSystemProfile.FocusProviderType, args: args)) { Debug.LogError("Failed to register the focus provider! The input system will not function without it."); return; } } else { #if UNITY_EDITOR InputMappingAxisUtility.RemoveMappings(ControllerMappingLibrary.UnityInputManagerAxes); #endif } // If the Boundary system has been selected for initialization in the Active profile, enable it in the project if (ActiveProfile.IsBoundarySystemEnabled) { object[] args = { this, ActiveProfile.BoundaryVisualizationProfile, ActiveProfile.TargetExperienceScale }; if (!RegisterService <IMixedRealityBoundarySystem>(ActiveProfile.BoundarySystemSystemType, args: args) || BoundarySystem == null) { Debug.LogError("Failed to start the Boundary System!"); } } // If the Camera system has been selected for initialization in the Active profile, enable it in the project if (ActiveProfile.IsCameraSystemEnabled) { object[] args = { this, ActiveProfile.CameraProfile }; if (!RegisterService <IMixedRealityCameraSystem>(ActiveProfile.CameraSystemType, args: args) || CameraSystem == null) { Debug.LogError("Failed to start the Camera System!"); } } // If the Spatial Awareness system has been selected for initialization in the Active profile, enable it in the project if (ActiveProfile.IsSpatialAwarenessSystemEnabled) { #if UNITY_EDITOR LayerExtensions.SetupLayer(31, "Spatial Awareness"); #endif object[] args = { this, ActiveProfile.SpatialAwarenessSystemProfile }; if (!RegisterService <IMixedRealitySpatialAwarenessSystem>(ActiveProfile.SpatialAwarenessSystemSystemType, args: args) && SpatialAwarenessSystem != null) { Debug.LogError("Failed to start the Spatial Awareness System!"); } } // If the Teleport system has been selected for initialization in the Active profile, enable it in the project if (ActiveProfile.IsTeleportSystemEnabled) { object[] args = { this }; if (!RegisterService <IMixedRealityTeleportSystem>(ActiveProfile.TeleportSystemSystemType, args: args) || TeleportSystem == null) { Debug.LogError("Failed to start the Teleport System!"); } } if (ActiveProfile.IsDiagnosticsSystemEnabled) { object[] args = { this, ActiveProfile.DiagnosticsSystemProfile }; if (!RegisterService <IMixedRealityDiagnosticsSystem>(ActiveProfile.DiagnosticsSystemSystemType, args: args) || DiagnosticsSystem == null) { Debug.LogError("Failed to start the Diagnostics System!"); } } if (ActiveProfile.RegisteredServiceProvidersProfile != null) { for (int i = 0; i < ActiveProfile.RegisteredServiceProvidersProfile?.Configurations?.Length; i++) { var configuration = ActiveProfile.RegisteredServiceProvidersProfile.Configurations[i]; if (typeof(IMixedRealityExtensionService).IsAssignableFrom(configuration.ComponentType.Type)) { object[] args = { this, configuration.ComponentName, configuration.Priority, configuration.ConfigurationProfile }; if (!RegisterService <IMixedRealityExtensionService>(configuration.ComponentType, configuration.RuntimePlatform, args)) { Debug.LogError($"Failed to register {configuration.ComponentName}"); } } } } #endregion Service Registration #region Services Initialization var orderedCoreSystems = activeSystems.OrderBy(m => m.Value.Priority).ToArray(); activeSystems.Clear(); foreach (var system in orderedCoreSystems) { RegisterServiceInternal(system.Key, system.Value); } var orderedServices = registeredMixedRealityServices.OrderBy(service => service.Item2.Priority).ToArray(); registeredMixedRealityServices.Clear(); foreach (var service in orderedServices) { RegisterServiceInternal(service.Item1, service.Item2); } InitializeAllServices(); #endregion Services Initialization isInitializing = false; }
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); // Make sure Unity axis mappings are set. InputMappingAxisUtility.CheckUnityInputManagerMappings(ControllerMappingLibrary.UnityInputManagerAxes); changed |= RenderProfile(inputSystemProfile, null, true, false, typeof(IMixedRealityInputSystem)); } else { RenderSystemDisabled(service); InputMappingAxisUtility.RemoveMappings(ControllerMappingLibrary.UnityInputManagerAxes); } 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); }, }; } }