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

Change requests for controller provider inspectors #526

Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public class SimulatedControllerDataProviderProfile : BaseMixedRealityController
{
#region General Settings

[Header("General Settings")]

[SerializeField]
[Tooltip("Simulated update frequency for tracking data in milliseconds. 0ms is every frame.")]
private double simulatedUpdateFrequency = 0;
Expand All @@ -35,8 +33,6 @@ public class SimulatedControllerDataProviderProfile : BaseMixedRealityController

#region Placement Settings

[Header("Placement Settings")]

[SerializeField]
[Tooltip("Default distance of the controller from the camera")]
private float defaultDistance = 0.5f;
Expand Down Expand Up @@ -68,8 +64,6 @@ public class SimulatedControllerDataProviderProfile : BaseMixedRealityController

#region Controls Settings

[Header("Controls Settings")]

[SerializeField]
[Tooltip("Key to toggle persistent mode for the left controller")]
private KeyCode toggleLeftPersistentKey = KeyCode.T;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEditor;
using UnityEngine;

namespace XRTK.Inspectors.Extensions
{
/// <summary>
/// Extensions for <see cref="EditorGUILayout"/> usage.
/// </summary>
public static class EditorGUILayoutExtensions
{
/// <summary>
/// Draws a foldout but with bold label text.
/// </summary>
/// <param name="foldout">Foldout state.</param>
/// <param name="content">Foldout label content.</param>
/// <param name="toggleOnLabelClick">Should the foldout toggle on label click?</param>
/// <returns>Returns true, if foldout unfolded.</returns>
public static bool FoldoutWithBoldLabel(bool foldout, GUIContent content, bool toggleOnLabelClick)
{
GUIStyle defaultStyle = EditorStyles.foldout;
FontStyle previousStyle = defaultStyle.fontStyle;
defaultStyle.fontStyle = FontStyle.Bold;
foldout = EditorGUILayout.Foldout(foldout, content, toggleOnLabelClick);
defaultStyle.fontStyle = previousStyle;

return foldout;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using XRTK.Inspectors.Extensions;
using XRTK.Inspectors.PropertyDrawers;
using XRTK.Providers.Controllers;
using XRTK.Extensions;

namespace XRTK.Inspectors.Profiles.InputSystem.Controllers
{
Expand All @@ -26,6 +27,8 @@ public class BaseMixedRealityControllerDataProviderProfileInspector : BaseMixedR

private ReorderableList mappingProfileList;
private int currentlySelectedElement;
private int selectedMappingsViewModeTab = 0;
private GUIStyle controllerButtonStyle;

protected override void OnEnable()
{
Expand Down Expand Up @@ -168,17 +171,86 @@ public override void OnInspectorGUI()
{
RenderHeader("This profile defines all of the controllers and their mappings to use. Additional platform settings can also be available as well.");

showMappingProfiles = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showMappingProfiles, new GUIContent("Controller Mapping Profiles"), true);
FejZa marked this conversation as resolved.
Show resolved Hide resolved
if (showMappingProfiles)
{
EditorGUILayout.Space();
selectedMappingsViewModeTab = GUILayout.Toolbar(selectedMappingsViewModeTab, new string[] { "Simple", "Advanced" });
FejZa marked this conversation as resolved.
Show resolved Hide resolved
switch (selectedMappingsViewModeTab)
{
case 0:
DrawSimpleControllerMappingProfilesView();
break;
case 1:
DrawAdvancedControllerMappingProfilesView();
break;
}
}

EditorGUILayout.Space();
}

private void DrawAdvancedControllerMappingProfilesView()
{
serializedObject.Update();
mappingProfileList.DoLayoutList();
serializedObject.ApplyModifiedProperties();
}

showMappingProfiles = EditorGUILayout.Foldout(showMappingProfiles, new GUIContent("Controller Mapping Profiles"), true);
private void DrawSimpleControllerMappingProfilesView()
{
if (controllerButtonStyle == null)
FejZa marked this conversation as resolved.
Show resolved Hide resolved
{
controllerButtonStyle = new GUIStyle("LargeButton")
{
imagePosition = ImagePosition.ImageAbove,
fontStyle = FontStyle.Bold,
stretchHeight = true,
stretchWidth = true,
wordWrap = true,
fontSize = 10,
};
}

if (showMappingProfiles)
bool appliedModifications = false;
serializedObject.Update();

for (int i = 0; i < controllerMappingProfiles?.arraySize; i++)
{
mappingProfileList.DoLayoutList();
var targetObjectReference = controllerMappingProfiles.GetArrayElementAtIndex(i)?.objectReferenceValue;
FejZa marked this conversation as resolved.
Show resolved Hide resolved
var controllerMappingProfile = (MixedRealityControllerMappingProfile)targetObjectReference;

// In advanced mode new profiel entries might have been created
// but not assiged, which leads to null entries in the mapping profiles list.
// We can safely ignore those for the simplified view.
if (controllerMappingProfile != null)
{
var handedness = controllerMappingProfile.Handedness;

if (handedness != Handedness.Right)
{
GUILayout.BeginHorizontal();
}

var buttonContent = new GUIContent($"Edit {controllerMappingProfile.name.ToProperCase()}", ControllerMappingLibrary.GetControllerTextureScaled(controllerMappingProfile));
if (GUILayout.Button(buttonContent, controllerButtonStyle, GUILayout.Height(128f), GUILayout.MinWidth(32f), GUILayout.ExpandWidth(true)))
{
serializedObject.ApplyModifiedProperties();
EditorApplication.delayCall += () => ControllerPopupWindow.Show(controllerMappingProfile, new SerializedObject(controllerMappingProfile).FindProperty("interactionMappingProfiles"));
FejZa marked this conversation as resolved.
Show resolved Hide resolved
appliedModifications = true;
}

if (handedness != Handedness.Left)
{
GUILayout.EndHorizontal();
}
}
}

serializedObject.ApplyModifiedProperties();
EditorGUILayout.Space();
if (!appliedModifications)
FejZa marked this conversation as resolved.
Show resolved Hide resolved
{
serializedObject.ApplyModifiedProperties();
}
}

private void DrawConfigurationOptionElement(Rect position, int index, bool isActive, bool isFocused)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEditor;
using UnityEngine;
using XRTK.Definitions.Controllers.Hands;
using XRTK.Inspectors.Extensions;

namespace XRTK.Inspectors.Profiles.InputSystem.Controllers
{
Expand All @@ -14,6 +16,8 @@ public class BaseMixedRealityHandControllerDataProviderProfileInspector : BaseMi
private SerializedProperty useTriggers;
private SerializedProperty boundsMode;

private bool showHandTrackingSettings = true;

protected override void OnEnable()
{
base.OnEnable();
Expand All @@ -27,14 +31,29 @@ protected override void OnEnable()
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUILayout.LabelField("Hand Rendering Settings", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(handMeshingEnabled);
EditorGUILayout.Space();
EditorGUILayout.LabelField("Hand Physics Settings", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(handPhysicsEnabled);
EditorGUILayout.PropertyField(useTriggers);
EditorGUILayout.PropertyField(boundsMode);
EditorGUILayout.Space();

serializedObject.Update();

showHandTrackingSettings = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showHandTrackingSettings, new GUIContent("Hand Tracking Settings"), true);
FejZa marked this conversation as resolved.
Show resolved Hide resolved
if (showHandTrackingSettings)
{
EditorGUI.indentLevel++;
EditorGUILayout.LabelField("Hand Rendering Settings");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(handMeshingEnabled);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Hand Physics Settings");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(handPhysicsEnabled);
EditorGUILayout.PropertyField(useTriggers);
EditorGUILayout.PropertyField(boundsMode);
EditorGUILayout.Space();
EditorGUI.indentLevel--;
EditorGUI.indentLevel--;
}

serializedObject.ApplyModifiedProperties();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEditor;
using UnityEngine;
using XRTK.Definitions.Controllers.Simulation;
using XRTK.Inspectors.Extensions;

namespace XRTK.Inspectors.Profiles.InputSystem.Controllers.Simulation
{
Expand All @@ -23,6 +25,8 @@ public class SimulatedControllerDataProviderProfileInspector : BaseMixedRealityC

private SerializedProperty rotationSpeed;

private bool showSimulationSettings = true;

protected override void OnEnable()
{
base.OnEnable();
Expand All @@ -48,21 +52,38 @@ public override void OnInspectorGUI()

serializedObject.Update();

EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(simulatedUpdateFrequency);
EditorGUILayout.PropertyField(controllerHideTimeout);
EditorGUILayout.Space();

EditorGUILayout.PropertyField(defaultDistance);
EditorGUILayout.PropertyField(depthMultiplier);
EditorGUILayout.PropertyField(jitterAmount);
EditorGUILayout.Space();

EditorGUILayout.PropertyField(toggleLeftPersistentKey);
EditorGUILayout.PropertyField(leftControllerTrackedKey);
EditorGUILayout.PropertyField(toggleRightPersistentKey);
EditorGUILayout.PropertyField(rightControllerTrackedKey);
EditorGUILayout.PropertyField(rotationSpeed);
showSimulationSettings = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showSimulationSettings, new GUIContent("Simulation Settings"), true);
FejZa marked this conversation as resolved.
Show resolved Hide resolved
if (showSimulationSettings)
{
EditorGUI.indentLevel++;

EditorGUILayout.LabelField("General Settings");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(simulatedUpdateFrequency);
EditorGUILayout.PropertyField(controllerHideTimeout);
EditorGUILayout.Space();
EditorGUI.indentLevel--;

EditorGUILayout.LabelField("Placement Settings");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(defaultDistance);
EditorGUILayout.PropertyField(depthMultiplier);
EditorGUILayout.PropertyField(jitterAmount);
EditorGUILayout.Space();
EditorGUI.indentLevel--;

EditorGUILayout.LabelField("Controls Settings");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(toggleLeftPersistentKey);
EditorGUILayout.PropertyField(leftControllerTrackedKey);
EditorGUILayout.PropertyField(toggleRightPersistentKey);
EditorGUILayout.PropertyField(rightControllerTrackedKey);
EditorGUILayout.PropertyField(rotationSpeed);
EditorGUI.indentLevel--;

EditorGUI.indentLevel--;

}

serializedObject.ApplyModifiedProperties();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using UnityEditorInternal;
using UnityEngine;
using XRTK.Definitions.Controllers.Simulation.Hands;
using XRTK.Inspectors.Extensions;

namespace XRTK.Inspectors.Profiles.InputSystem.Controllers.Simulation
{
Expand All @@ -22,6 +23,8 @@ public class SimulatedHandControllerDataProviderProfileInspector : SimulatedCont
private ReorderableList poseList;
private int currentlySelectedElement;

private bool showSimulatedHandTrackingSettings = true;

protected override void OnEnable()
{
base.OnEnable();
Expand Down Expand Up @@ -56,18 +59,30 @@ public override void OnInspectorGUI()
serializedObject.Update();

EditorGUILayout.Space();
EditorGUILayout.LabelField("Hand Rendering Settings", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(handMeshingEnabled);
EditorGUILayout.LabelField("Hand Physics Settings", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(handPhysicsEnabled);
EditorGUILayout.PropertyField(useTriggers);
EditorGUILayout.PropertyField(boundsMode);
EditorGUILayout.Space();

EditorGUILayout.LabelField("Hand Simulation Settings", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(handPoseAnimationSpeed);

poseList.DoLayoutList();
showSimulatedHandTrackingSettings = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showSimulatedHandTrackingSettings, new GUIContent("Simulated Hand Tracking Settings"), true);
FejZa marked this conversation as resolved.
Show resolved Hide resolved
if (showSimulatedHandTrackingSettings)
{
EditorGUI.indentLevel++;
EditorGUILayout.LabelField("Hand Rendering Settings");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(handMeshingEnabled);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Hand Physics Settings");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(handPhysicsEnabled);
EditorGUILayout.PropertyField(useTriggers);
EditorGUILayout.PropertyField(boundsMode);
EditorGUILayout.Space();
EditorGUI.indentLevel--;
EditorGUILayout.LabelField("Simulated Poses");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(handPoseAnimationSpeed);
poseList.DoLayoutList();
EditorGUI.indentLevel--;
EditorGUI.indentLevel--;
}

serializedObject.ApplyModifiedProperties();
}
Expand Down