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

Commit cb0afa2

Browse files
clickable services without having to open foldout (#848)
* clickable services without having to open foldout * updated visual style a bit * fixed a misc bug in input system inspector * fixed an invalid cast excpetion when navigating back to the input system profile from a controller data provider updated service clickablility when no profile is required * a few tweaks to the spacing * fixed a NRE when assigning a profile to an expended service reference updated profiles * updated submodules * updated examples submodule
1 parent d3754f5 commit cb0afa2

6 files changed

Lines changed: 56 additions & 16 deletions

File tree

Submodules/Lumin

Submodule Lumin updated from 7c36505 to adac944

Submodules/WindowsMixedReality

XRTK-Core/Packages/com.xrtk.core/Editor/Profiles/InputSystem/MixedRealityInputSystemProfileInspector.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class MixedRealityInputSystemProfileInspector : MixedRealityServiceProfil
2121
{
2222
private static readonly GUIContent FocusProviderContent = new GUIContent("Focus Provider");
2323
private static readonly GUIContent GazeProviderContent = new GUIContent("Gaze Provider");
24+
private static readonly GUIContent GazeCursorPrefabContent = new GUIContent("Gaze Cursor Prefab");
2425
private static readonly GUIContent GlobalPointerSettingsContent = new GUIContent("Global Pointer Settings");
2526
private static readonly GUIContent GlobalHandSettingsContent = new GUIContent("Global Hand Settings");
2627
private static readonly GUIContent ShowControllerMappingsContent = new GUIContent("Controller Action Mappings");
@@ -83,10 +84,10 @@ protected override void OnEnable()
8384
{
8485
var configurationProperty = Configurations.GetArrayElementAtIndex(i);
8586
var configurationProfileProperty = configurationProperty.FindPropertyRelative("profile");
86-
if (configurationProfileProperty != null)
87-
{
88-
var controllerDataProviderProfile = (BaseMixedRealityControllerDataProviderProfile)configurationProfileProperty.objectReferenceValue;
8987

88+
if (configurationProfileProperty != null &&
89+
configurationProfileProperty.objectReferenceValue is BaseHandControllerDataProviderProfile controllerDataProviderProfile)
90+
{
9091
if (controllerDataProviderProfile.IsNull() ||
9192
controllerDataProviderProfile.ControllerMappingProfiles == null)
9293
{
@@ -126,7 +127,7 @@ public override void OnInspectorGUI()
126127

127128
EditorGUILayout.PropertyField(focusProviderType, FocusProviderContent);
128129
EditorGUILayout.PropertyField(gazeProviderType, GazeProviderContent);
129-
EditorGUILayout.PropertyField(gazeCursorPrefab);
130+
EditorGUILayout.PropertyField(gazeCursorPrefab, GazeCursorPrefabContent);
130131

131132
EditorGUILayout.Space();
132133

XRTK-Core/Packages/com.xrtk.core/Editor/Profiles/MixedRealityServiceProviderProfileInspector.cs

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public class MixedRealityServiceProfileInspector : BaseMixedRealityProfileInspec
4242

4343
private List<Tuple<bool, bool>> configListHeightFlags;
4444

45+
private GUIStyle buttonGuiStyle = null;
46+
47+
private GUIStyle ButtonGuiStyle => buttonGuiStyle ?? (buttonGuiStyle =
48+
new GUIStyle(EditorStyles.toolbarButton)
49+
{
50+
alignment = TextAnchor.MiddleLeft,
51+
fontStyle = FontStyle.Bold
52+
});
53+
4554
protected override void OnEnable()
4655
{
4756
base.OnEnable();
@@ -183,17 +192,20 @@ private void DrawConfigurationOptionElement(Rect rect, int index, bool isActive,
183192

184193
var rectX = rect.x + 12;
185194
var rectWidth = rect.width - 12;
186-
var nameRect = new Rect(rectX, rect.y + halfFieldHeight, rectWidth, EditorGUIUtility.singleLineHeight);
187-
var typeRect = new Rect(rectX, rect.y + halfFieldHeight * 6, rectWidth, EditorGUIUtility.singleLineHeight);
188-
var profileRect = new Rect(rectX, rect.y + halfFieldHeight * 11, rectWidth, EditorGUIUtility.singleLineHeight);
189-
var runtimeRect = new Rect(rectX, rect.y + halfFieldHeight * (hasProfile ? 16 : 11), rectWidth, EditorGUIUtility.singleLineHeight);
195+
var elementX = rectX + 6;
196+
var elementWidth = rectWidth - 6;
197+
var dropdownRect = new Rect(rectX, rect.y + halfFieldHeight, rectWidth, EditorGUIUtility.singleLineHeight);
198+
var labelRect = new Rect(elementX, rect.y + halfFieldHeight, elementWidth, EditorGUIUtility.singleLineHeight);
199+
var typeRect = new Rect(elementX, rect.y + halfFieldHeight * 6, elementWidth, EditorGUIUtility.singleLineHeight);
200+
var profileRect = new Rect(elementX, rect.y + halfFieldHeight * 11, elementWidth, EditorGUIUtility.singleLineHeight);
201+
var runtimeRect = new Rect(elementX, rect.y + halfFieldHeight * (hasProfile ? 16 : 11), elementWidth, EditorGUIUtility.singleLineHeight);
190202

191203
EditorGUI.BeginChangeCheck();
192204

193205
if (configurationProperty.isExpanded)
194206
{
195-
EditorGUI.PropertyField(nameRect, nameProperty);
196-
configurationProperty.isExpanded = EditorGUI.Foldout(nameRect, configurationProperty.isExpanded, GUIContent.none, true);
207+
EditorGUI.PropertyField(labelRect, nameProperty);
208+
configurationProperty.isExpanded = EditorGUI.Foldout(dropdownRect, configurationProperty.isExpanded, GUIContent.none, true);
197209

198210
if (!configurationProperty.isExpanded)
199211
{
@@ -202,7 +214,34 @@ private void DrawConfigurationOptionElement(Rect rect, int index, bool isActive,
202214
}
203215
else
204216
{
205-
configurationProperty.isExpanded = EditorGUI.Foldout(nameRect, configurationProperty.isExpanded, nameProperty.stringValue, true);
217+
configurationProperty.isExpanded = EditorGUI.Foldout(dropdownRect, configurationProperty.isExpanded, GUIContent.none, false) ||
218+
hasProfile && configurationProfileProperty.objectReferenceValue == null;
219+
220+
if (!configurationProfileProperty.isExpanded)
221+
{
222+
if (hasProfile)
223+
{
224+
if (GUI.Button(labelRect, nameProperty.stringValue, ButtonGuiStyle) &&
225+
configurationProfileProperty.objectReferenceValue != null)
226+
{
227+
var profile = configurationProfileProperty.objectReferenceValue as BaseMixedRealityProfile;
228+
229+
Debug.Assert(profile != null);
230+
231+
if (profile.ParentProfile.IsNull() ||
232+
profile.ParentProfile != ThisProfile)
233+
{
234+
profile.ParentProfile = ThisProfile;
235+
}
236+
237+
Selection.activeObject = profile;
238+
}
239+
}
240+
else
241+
{
242+
GUI.Label(labelRect, nameProperty.stringValue, ButtonGuiStyle);
243+
}
244+
}
206245
}
207246

208247
if (configurationProperty.isExpanded)

XRTK-Core/Packages/com.xrtk.core/Editor/PropertyDrawers/MixedRealityProfilePropertyDrawer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
3535
{
3636
parent = ParentProfileOverride;
3737

38-
if (parent.IsNull())
38+
if (parent.IsNull() && Selection.activeObject.IsNotNull())
3939
{
4040
if (Selection.activeObject.name.Equals(nameof(MixedRealityToolkit)))
4141
{
@@ -128,4 +128,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
128128
EditorGUI.EndProperty();
129129
}
130130
}
131-
}
131+
}

0 commit comments

Comments
 (0)