Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Updated concept of "Configuration Profile" and Inspector Cleanup #483

Merged
merged 16 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Submodules/SDK
Submodule SDK updated from 844a06 to eedfeb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Test_01_InitializeMixedRealityToolkit()
}

[Test]
public void Test_02_TestNoMixedRealityConfigurationFound()
public void Test_02_TestNoMixedRealityProfileFound()
{
// Setup
TestUtilities.CleanupScene();
Expand All @@ -48,7 +48,7 @@ public void Test_02_TestNoMixedRealityConfigurationFound()
Assert.IsFalse(MixedRealityToolkit.HasActiveProfile);
Assert.IsNull(MixedRealityToolkit.Instance.ActiveProfile);
Assert.IsFalse(MixedRealityToolkit.HasActiveProfile);
LogAssert.Expect(LogType.Error, "No Mixed Reality Configuration Profile found, cannot initialize the Mixed Reality Toolkit");
LogAssert.Expect(LogType.Error, "No Mixed Reality Root Profile found, cannot initialize the Mixed Reality Toolkit");
}

[Test]
Expand Down
8 changes: 4 additions & 4 deletions XRTK-Core/Assets/XRTK.Tests/TestUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public static void InitializeMixedRealityToolkitScene(bool useDefaultProfile = f
Assert.IsFalse(MixedRealityToolkit.HasActiveProfile);

var configuration = useDefaultProfile
? GetDefaultMixedRealityProfile<MixedRealityToolkitConfigurationProfile>()
: ScriptableObject.CreateInstance<MixedRealityToolkitConfigurationProfile>();
? GetDefaultMixedRealityProfile<MixedRealityToolkitRootProfile>()
: ScriptableObject.CreateInstance<MixedRealityToolkitRootProfile>();

Assert.IsTrue(configuration != null, "Failed to find the Default Mixed Reality Configuration Profile");
MixedRealityToolkit.Instance.ResetConfiguration(configuration);
Assert.IsTrue(configuration != null, "Failed to find the Default Mixed Reality Settings Profile");
MixedRealityToolkit.Instance.ResetProfile(configuration);
Assert.IsTrue(MixedRealityToolkit.Instance.ActiveProfile != null);
Assert.IsTrue(MixedRealityToolkit.IsInitialized);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace XRTK.Definitions
{
/// <summary>
/// Base Profile for all data containers to use in the Mixed Reality Toolkit.
/// </summary>
public abstract class BaseMixedRealityProfile : ScriptableObject
{
[SerializeField]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public MixedRealityServiceConfiguration<TService>[] RegisteredServiceConfigurati
{
var cachedConfig = configurations[i];
Debug.Assert(cachedConfig != null);
var serviceConfig = new MixedRealityServiceConfiguration<TService>(cachedConfig.InstancedType, cachedConfig.Name, cachedConfig.Priority, cachedConfig.RuntimePlatforms, cachedConfig.ConfigurationProfile);
var serviceConfig = new MixedRealityServiceConfiguration<TService>(cachedConfig.InstancedType, cachedConfig.Name, cachedConfig.Priority, cachedConfig.RuntimePlatforms, cachedConfig.Profile);
Debug.Assert(serviceConfig != null);
serviceConfigurations[i] = serviceConfig;
}
Expand All @@ -59,7 +59,7 @@ internal set
{
var serviceConfig = serviceConfigurations[i];
Debug.Assert(serviceConfig != null);
var newConfig = new MixedRealityServiceConfiguration(serviceConfig.InstancedType, serviceConfig.Name, serviceConfig.Priority, serviceConfig.RuntimePlatforms, serviceConfig.ConfigurationProfile);
var newConfig = new MixedRealityServiceConfiguration(serviceConfig.InstancedType, serviceConfig.Name, serviceConfig.Priority, serviceConfig.RuntimePlatforms, serviceConfig.Profile);
Debug.Assert(newConfig != null);
configurations[i] = newConfig;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class MixedRealityServiceConfiguration<T> : MixedRealityServiceConfigurat
where T : IMixedRealityService
{
/// <inheritdoc />
public MixedRealityServiceConfiguration(SystemType instancedType, string name, uint priority, IReadOnlyList<IMixedRealityPlatform> runtimePlatforms, BaseMixedRealityProfile configurationProfile)
: base(instancedType, name, priority, runtimePlatforms, configurationProfile)
public MixedRealityServiceConfiguration(SystemType instancedType, string name, uint priority, IReadOnlyList<IMixedRealityPlatform> runtimePlatforms, BaseMixedRealityProfile profile)
: base(instancedType, name, priority, runtimePlatforms, profile)
{
}
}
Expand All @@ -36,8 +36,8 @@ public class MixedRealityServiceConfiguration : IMixedRealityServiceConfiguratio
/// <param name="name">The simple, human readable name for the <see cref="IMixedRealityService"/>.</param>
/// <param name="priority">The priority this <see cref="IMixedRealityService"/> will be initialized in.</param>
/// <param name="runtimePlatforms">runtimePlatform">The runtime platform(s) to run this <see cref="IMixedRealityService"/> to run on.</param>
/// <param name="configurationProfile">The configuration profile for <see cref="IMixedRealityService"/>.</param>
public MixedRealityServiceConfiguration(SystemType instancedType, string name, uint priority, IReadOnlyList<IMixedRealityPlatform> runtimePlatforms, BaseMixedRealityProfile configurationProfile)
/// <param name="profile">The <see cref="BaseMixedRealityProfile"/> for <see cref="IMixedRealityService"/>.</param>
public MixedRealityServiceConfiguration(SystemType instancedType, string name, uint priority, IReadOnlyList<IMixedRealityPlatform> runtimePlatforms, BaseMixedRealityProfile profile)
{
this.instancedType = instancedType;
this.name = name;
Expand All @@ -55,7 +55,7 @@ public MixedRealityServiceConfiguration(SystemType instancedType, string name, u
platformEntries = new RuntimePlatformEntry(runtimePlatforms);
}

this.configurationProfile = configurationProfile;
this.profile = profile;
}

[SerializeField]
Expand Down Expand Up @@ -142,13 +142,14 @@ public IReadOnlyList<IMixedRealityPlatform> RuntimePlatforms
}

[SerializeField]
private BaseMixedRealityProfile configurationProfile;
[FormerlySerializedAs("configurationProfile")]
private BaseMixedRealityProfile profile;

/// <inheritdoc />
public BaseMixedRealityProfile ConfigurationProfile
public BaseMixedRealityProfile Profile
{
get => configurationProfile;
internal set => configurationProfile = value;
get => profile;
internal set => profile = value;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEngine;
Expand All @@ -20,12 +20,12 @@
namespace XRTK.Definitions
{
/// <summary>
/// Configuration profile settings for the Mixed Reality Toolkit.
/// The root profile for the Mixed Reality Toolkit's settings.
/// </summary>
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Mixed Reality Toolkit Configuration Profile", fileName = "MixedRealityToolkitConfigurationProfile", order = (int)CreateProfileMenuItemIndices.Configuration)]
public class MixedRealityToolkitConfigurationProfile : BaseMixedRealityProfile
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Mixed Reality Toolkit Root Profile", fileName = "MixedRealityToolkitRootProfile", order = (int)CreateProfileMenuItemIndices.Configuration)]
public sealed class MixedRealityToolkitRootProfile : BaseMixedRealityProfile
{
#region Mixed Reality Toolkit configurable properties
#region Mixed Reality Toolkit system properties

#region Camera System Properties

Expand Down Expand Up @@ -323,6 +323,8 @@ public SystemType DiagnosticsSystemSystemType

#endregion Diagnostics System Properties

#endregion Mixed Reality Toolkit system properties

[SerializeField]
[Tooltip("All the additional non-required services registered with the Mixed Reality Toolkit.")]
private MixedRealityRegisteredServiceProvidersProfile registeredServiceProvidersProfile = null;
Expand All @@ -335,7 +337,5 @@ public MixedRealityRegisteredServiceProvidersProfile RegisteredServiceProvidersP
get => registeredServiceProvidersProfile;
internal set => registeredServiceProvidersProfile = value;
}

#endregion Mixed Reality Toolkit configurable properties
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MixedRealityToolkitInspector : BaseMixedRealityToolkitInspector

private void OnEnable()
{
activeProfile = serializedObject.FindProperty("activeProfile");
activeProfile = serializedObject.FindProperty(nameof(activeProfile));
currentPickerWindow = -1;
checkChange = activeProfile.objectReferenceValue == null;
}
Expand All @@ -39,22 +39,22 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(activeProfile);
var changed = EditorGUI.EndChangeCheck();
var commandName = Event.current.commandName;
var allConfigProfiles = ScriptableObjectExtensions.GetAllInstances<MixedRealityToolkitConfigurationProfile>();
var profiles = ScriptableObjectExtensions.GetAllInstances<MixedRealityToolkitRootProfile>();

if (activeProfile.objectReferenceValue == null)
{
if (currentPickerWindow == -1 && checkChange)
{
if (allConfigProfiles.Length > 1)
if (profiles.Length > 1)
{
EditorUtility.DisplayDialog("Attention!", "You must choose a profile for the Mixed Reality Toolkit.", "OK");
currentPickerWindow = GUIUtility.GetControlID(FocusType.Passive);
EditorGUIUtility.ShowObjectPicker<MixedRealityToolkitConfigurationProfile>(
GetDefaultProfile(allConfigProfiles), false, string.Empty, currentPickerWindow);
EditorGUIUtility.ShowObjectPicker<MixedRealityToolkitRootProfile>(
GetDefaultProfile(profiles), false, string.Empty, currentPickerWindow);
}
else if (allConfigProfiles.Length == 1)
else if (profiles.Length == 1)
{
var profile = allConfigProfiles[0];
var profile = profiles[0];
activeProfile.objectReferenceValue = profile;
changed = true;
EditorApplication.delayCall += () =>
Expand All @@ -67,9 +67,9 @@ public override void OnInspectorGUI()
checkChange = false;
}

if (GUILayout.Button("Create new configuration"))
if (GUILayout.Button("Create new settings profile"))
{
var profile = CreateInstance(nameof(MixedRealityToolkitConfigurationProfile));
var profile = CreateInstance(nameof(MixedRealityToolkitRootProfile));
profile.CreateAsset();
activeProfile.objectReferenceValue = profile;
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public override void OnInspectorGUI()

if (changed)
{
EditorApplication.delayCall += () => MixedRealityToolkit.Instance.ResetConfiguration((MixedRealityToolkitConfigurationProfile)activeProfile.objectReferenceValue);
EditorApplication.delayCall += () => MixedRealityToolkit.Instance.ResetProfile((MixedRealityToolkitRootProfile)activeProfile.objectReferenceValue);
}
}

Expand Down Expand Up @@ -166,9 +166,9 @@ void SetStartScene()
}
}

private static MixedRealityToolkitConfigurationProfile GetDefaultProfile(IEnumerable<MixedRealityToolkitConfigurationProfile> allProfiles)
private static MixedRealityToolkitRootProfile GetDefaultProfile(IEnumerable<MixedRealityToolkitRootProfile> profiles)
{
return allProfiles.FirstOrDefault(profile => profile.name == "DefaultMixedRealityToolkitConfigurationProfile");
return profiles.FirstOrDefault(profile => profile.name == $"Default{nameof(MixedRealityToolkitRootProfile)}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static bool RenderProfileInternal(BaseMixedRealityProfile parentProfile,
var renderedProfile = property.objectReferenceValue as BaseMixedRealityProfile;
Debug.Assert(renderedProfile != null);

if (!(renderedProfile is MixedRealityToolkitConfigurationProfile) &&
if (!(renderedProfile is MixedRealityToolkitRootProfile) &&
(renderedProfile.ParentProfile == null ||
renderedProfile.ParentProfile != parentProfile))
{
Expand Down Expand Up @@ -204,11 +204,11 @@ protected static async void CreateCloneProfile()

if (!profileToCopy.IsEditable)
{
// For now we only replace it if it's the master configuration profile.
// Sub-profiles are easy to update in the master configuration inspector.
// For now we only replace it if it's the master settings profile.
// Sub-profiles are easy to update in the master settings inspector.
if (MixedRealityToolkit.Instance.ActiveProfile.GetType() == profile.GetType())
{
MixedRealityToolkit.Instance.ActiveProfile = profile as MixedRealityToolkitConfigurationProfile;
MixedRealityToolkit.Instance.ActiveProfile = profile as MixedRealityToolkitRootProfile;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public override void OnInspectorGUI()

if (changed && MixedRealityToolkit.IsInitialized)
{
EditorApplication.delayCall += () => MixedRealityToolkit.Instance.ResetConfiguration(MixedRealityToolkit.Instance.ActiveProfile);
EditorApplication.delayCall += () => MixedRealityToolkit.Instance.ResetProfile(MixedRealityToolkit.Instance.ActiveProfile);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected override void OnEnable()
{
base.OnEnable();

gestures = serializedObject.FindProperty("gestures");
gestures = serializedObject.FindProperty(nameof(gestures));

gesturesProfile = target as MixedRealityGesturesProfile;
Debug.Assert(gesturesProfile != null);
Expand Down Expand Up @@ -79,13 +79,7 @@ private void UpdateGestureLabels()

public override void OnInspectorGUI()
{
MixedRealityInspectorUtility.RenderMixedRealityToolkitLogo();

if (inputSystemProfile != null &&
GUILayout.Button("Back to Input Profile"))
{
Selection.activeObject = inputSystemProfile;
}
RenderHeader();

EditorGUILayout.Space();
EditorGUILayout.LabelField("Gesture Input", EditorStyles.boldLabel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEditor;
using UnityEngine;
using XRTK.Definitions.InputSystem;
using XRTK.Inspectors.Utilities;
using XRTK.Services;
Expand All @@ -26,26 +25,20 @@ protected override void OnEnable()
{
base.OnEnable();

focusProviderType = serializedObject.FindProperty("focusProviderType");
inputActionsProfile = serializedObject.FindProperty("inputActionsProfile");
inputActionRulesProfile = serializedObject.FindProperty("inputActionRulesProfile");
pointerProfile = serializedObject.FindProperty("pointerProfile");
gesturesProfile = serializedObject.FindProperty("gesturesProfile");
speechCommandsProfile = serializedObject.FindProperty("speechCommandsProfile");
controllerVisualizationProfile = serializedObject.FindProperty("controllerVisualizationProfile");
controllerDataProvidersProfile = serializedObject.FindProperty("controllerDataProvidersProfile");
controllerMappingProfiles = serializedObject.FindProperty("controllerMappingProfiles");
focusProviderType = serializedObject.FindProperty(nameof(focusProviderType));
inputActionsProfile = serializedObject.FindProperty(nameof(inputActionsProfile));
inputActionRulesProfile = serializedObject.FindProperty(nameof(inputActionRulesProfile));
pointerProfile = serializedObject.FindProperty(nameof(pointerProfile));
gesturesProfile = serializedObject.FindProperty(nameof(gesturesProfile));
speechCommandsProfile = serializedObject.FindProperty(nameof(speechCommandsProfile));
controllerVisualizationProfile = serializedObject.FindProperty(nameof(controllerVisualizationProfile));
controllerDataProvidersProfile = serializedObject.FindProperty(nameof(controllerDataProvidersProfile));
controllerMappingProfiles = serializedObject.FindProperty(nameof(controllerMappingProfiles));
}

public override void OnInspectorGUI()
{
MixedRealityInspectorUtility.RenderMixedRealityToolkitLogo();

if (ThisProfile.ParentProfile != null &&
GUILayout.Button("Back to Configuration Profile"))
{
Selection.activeObject = ThisProfile.ParentProfile;
}
RenderHeader();

EditorGUILayout.Space();
EditorGUILayout.LabelField("Input System Profile", EditorStyles.boldLabel);
Expand Down Expand Up @@ -77,7 +70,7 @@ public override void OnInspectorGUI()

if (changed && MixedRealityToolkit.IsInitialized)
{
EditorApplication.delayCall += () => MixedRealityToolkit.Instance.ResetConfiguration(MixedRealityToolkit.Instance.ActiveProfile);
EditorApplication.delayCall += () => MixedRealityToolkit.Instance.ResetProfile(MixedRealityToolkit.Instance.ActiveProfile);
}
}
}
Expand Down
Loading