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

Commit

Permalink
clickable services without having to open foldout (#848)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
StephenHodgson committed Jun 4, 2021
1 parent 1997ae2 commit 0f0b333
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();

Expand Down
53 changes: 46 additions & 7 deletions Editor/Profiles/MixedRealityServiceProviderProfileInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ public class MixedRealityServiceProfileInspector : BaseMixedRealityProfileInspec

private List<Tuple<bool, bool>> 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();
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Editor/PropertyDrawers/MixedRealityProfilePropertyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
{
Expand Down Expand Up @@ -128,4 +128,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
EditorGUI.EndProperty();
}
}
}
}

0 comments on commit 0f0b333

Please sign in to comment.