diff --git a/Editor/Profiles/InputSystem/MixedRealityInputSystemProfileInspector.cs b/Editor/Profiles/InputSystem/MixedRealityInputSystemProfileInspector.cs index 32f8078e2..1bb9b116d 100644 --- a/Editor/Profiles/InputSystem/MixedRealityInputSystemProfileInspector.cs +++ b/Editor/Profiles/InputSystem/MixedRealityInputSystemProfileInspector.cs @@ -21,6 +21,7 @@ public class MixedRealityInputSystemProfileInspector : MixedRealityServiceProfil { private static readonly GUIContent FocusProviderContent = new GUIContent("Focus Provider"); private static readonly GUIContent GazeProviderContent = new GUIContent("Gaze Provider"); + private static readonly GUIContent GazeCursorPrefabContent = new GUIContent("Gaze Cursor Prefab"); private static readonly GUIContent GlobalPointerSettingsContent = new GUIContent("Global Pointer Settings"); private static readonly GUIContent GlobalHandSettingsContent = new GUIContent("Global Hand Settings"); private static readonly GUIContent ShowControllerMappingsContent = new GUIContent("Controller Action Mappings"); @@ -83,10 +84,10 @@ protected override void OnEnable() { var configurationProperty = Configurations.GetArrayElementAtIndex(i); var configurationProfileProperty = configurationProperty.FindPropertyRelative("profile"); - if (configurationProfileProperty != null) - { - var controllerDataProviderProfile = (BaseMixedRealityControllerDataProviderProfile)configurationProfileProperty.objectReferenceValue; + if (configurationProfileProperty != null && + configurationProfileProperty.objectReferenceValue is BaseHandControllerDataProviderProfile controllerDataProviderProfile) + { if (controllerDataProviderProfile.IsNull() || controllerDataProviderProfile.ControllerMappingProfiles == null) { @@ -126,7 +127,7 @@ public override void OnInspectorGUI() EditorGUILayout.PropertyField(focusProviderType, FocusProviderContent); EditorGUILayout.PropertyField(gazeProviderType, GazeProviderContent); - EditorGUILayout.PropertyField(gazeCursorPrefab); + EditorGUILayout.PropertyField(gazeCursorPrefab, GazeCursorPrefabContent); EditorGUILayout.Space(); diff --git a/Editor/Profiles/MixedRealityServiceProviderProfileInspector.cs b/Editor/Profiles/MixedRealityServiceProviderProfileInspector.cs index 6d0573161..6b8d84b7c 100644 --- a/Editor/Profiles/MixedRealityServiceProviderProfileInspector.cs +++ b/Editor/Profiles/MixedRealityServiceProviderProfileInspector.cs @@ -42,6 +42,15 @@ public class MixedRealityServiceProfileInspector : BaseMixedRealityProfileInspec private List> configListHeightFlags; + private GUIStyle buttonGuiStyle = null; + + private GUIStyle ButtonGuiStyle => buttonGuiStyle ?? (buttonGuiStyle = + new GUIStyle(EditorStyles.toolbarButton) + { + alignment = TextAnchor.MiddleLeft, + fontStyle = FontStyle.Bold + }); + protected override void OnEnable() { base.OnEnable(); @@ -183,17 +192,20 @@ private void DrawConfigurationOptionElement(Rect rect, int index, bool isActive, var rectX = rect.x + 12; var rectWidth = rect.width - 12; - var nameRect = new Rect(rectX, rect.y + halfFieldHeight, rectWidth, EditorGUIUtility.singleLineHeight); - var typeRect = new Rect(rectX, rect.y + halfFieldHeight * 6, rectWidth, EditorGUIUtility.singleLineHeight); - var profileRect = new Rect(rectX, rect.y + halfFieldHeight * 11, rectWidth, EditorGUIUtility.singleLineHeight); - var runtimeRect = new Rect(rectX, rect.y + halfFieldHeight * (hasProfile ? 16 : 11), rectWidth, EditorGUIUtility.singleLineHeight); + var elementX = rectX + 6; + var elementWidth = rectWidth - 6; + var dropdownRect = new Rect(rectX, rect.y + halfFieldHeight, rectWidth, EditorGUIUtility.singleLineHeight); + var labelRect = new Rect(elementX, rect.y + halfFieldHeight, elementWidth, EditorGUIUtility.singleLineHeight); + var typeRect = new Rect(elementX, rect.y + halfFieldHeight * 6, elementWidth, EditorGUIUtility.singleLineHeight); + var profileRect = new Rect(elementX, rect.y + halfFieldHeight * 11, elementWidth, EditorGUIUtility.singleLineHeight); + var runtimeRect = new Rect(elementX, rect.y + halfFieldHeight * (hasProfile ? 16 : 11), elementWidth, EditorGUIUtility.singleLineHeight); EditorGUI.BeginChangeCheck(); if (configurationProperty.isExpanded) { - EditorGUI.PropertyField(nameRect, nameProperty); - configurationProperty.isExpanded = EditorGUI.Foldout(nameRect, configurationProperty.isExpanded, GUIContent.none, true); + EditorGUI.PropertyField(labelRect, nameProperty); + configurationProperty.isExpanded = EditorGUI.Foldout(dropdownRect, configurationProperty.isExpanded, GUIContent.none, true); if (!configurationProperty.isExpanded) { @@ -202,7 +214,34 @@ private void DrawConfigurationOptionElement(Rect rect, int index, bool isActive, } else { - configurationProperty.isExpanded = EditorGUI.Foldout(nameRect, configurationProperty.isExpanded, nameProperty.stringValue, true); + configurationProperty.isExpanded = EditorGUI.Foldout(dropdownRect, configurationProperty.isExpanded, GUIContent.none, false) || + hasProfile && configurationProfileProperty.objectReferenceValue == null; + + if (!configurationProfileProperty.isExpanded) + { + if (hasProfile) + { + if (GUI.Button(labelRect, nameProperty.stringValue, ButtonGuiStyle) && + configurationProfileProperty.objectReferenceValue != null) + { + var profile = configurationProfileProperty.objectReferenceValue as BaseMixedRealityProfile; + + Debug.Assert(profile != null); + + if (profile.ParentProfile.IsNull() || + profile.ParentProfile != ThisProfile) + { + profile.ParentProfile = ThisProfile; + } + + Selection.activeObject = profile; + } + } + else + { + GUI.Label(labelRect, nameProperty.stringValue, ButtonGuiStyle); + } + } } if (configurationProperty.isExpanded) diff --git a/Editor/PropertyDrawers/MixedRealityProfilePropertyDrawer.cs b/Editor/PropertyDrawers/MixedRealityProfilePropertyDrawer.cs index b622bddf7..801c5ace0 100644 --- a/Editor/PropertyDrawers/MixedRealityProfilePropertyDrawer.cs +++ b/Editor/PropertyDrawers/MixedRealityProfilePropertyDrawer.cs @@ -35,7 +35,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten { parent = ParentProfileOverride; - if (parent.IsNull()) + if (parent.IsNull() && Selection.activeObject.IsNotNull()) { if (Selection.activeObject.name.Equals(nameof(MixedRealityToolkit))) { @@ -128,4 +128,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten EditorGUI.EndProperty(); } } -} \ No newline at end of file +}