8000 Fixed simulated hand data provider Tracked Hand Pose list rendering by StephenHodgson · Pull Request #692 · XRTK/com.xrtk.core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Aug 11, 2024. It is now read-only.

Fixed simulated hand data provider Tracked Hand Pose list rendering #692

Merged
merged 1 commit into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Split
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ namespace XRTK.Editor.Profiles.InputSystem.Controllers
[CustomEditor(typeof(BaseHandControllerDataProviderProfile), true, isFallback = true)]
public class BaseMixedRealityHandControllerDataProviderProfileInspector : BaseMixedRealityControllerDataProviderProfileInspector
{
private static readonly GUIContent handTrackingSettingsFoldoutHeader = new GUIContent("Hand Tracking Settings");

private SerializedProperty renderingMode;
private SerializedProperty handPhysicsEnabled;
private SerializedProperty useTriggers;
private SerializedProperty boundsMode;
private SerializedProperty trackedPoses;

private bool showHandTrackingSettings = true;
private static readonly GUIContent handTrackingSettingsFoldoutHeader = new GUIContent("Hand Tracking Settings");

private ReorderableList poseProfilesList;
private int currentlySelectedPoseElement;
Expand Down Expand Up @@ -50,7 +51,10 @@ public override void OnInspectorGUI()

serializedObject.Update();

showHandTrackingSettings = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showHandTrackingSettings, handTrackingSettingsFoldoutHeader, true);
EditorGUILayout.Space();

showHandTrackingSettings = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showHandTrackingSettings, handTrackingSettingsFoldoutHeader);

if (showHandTrackingSettings)
{
EditorGUI.indentLevel++;
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 UnityEditorInternal;
using UnityEngine;
using XRTK.Definitions.Controllers.Hands;
using XRTK.Definitions.Controllers.Simulation.Hands;
using XRTK.Editor.Extensions;

Expand All @@ -22,6 +24,8 @@ public class SimulatedHandControllerDataProviderProfileInspector : SimulatedCont
private SerializedProperty handPoseAnimationSpeed;

private bool showSimulatedHandTrackingSettings = true;
private ReorderableList poseProfilesList;
private int currentlySelectedPoseElement;

protected override void OnEnable()
{
Expand All @@ -34,6 +38,15 @@ protected override void OnEnable()

trackedPoses = serializedObject.FindProperty(nameof(trackedPoses));

poseProfilesList = new ReorderableList(serializedObject, trackedPoses, true, false, true, true)
{
elementHeight = EditorGUIUtility.singleLineHeight * 1.5f
};
poseProfilesList.drawHeaderCallback += PoseProfilesList_DrawHeaderCallback;
poseProfilesList.drawElementCallback += PoseProfilesList_DrawConfigurationOptionElement;
poseProfilesList.onAddCallback += PoseProfilesList_OnConfigurationOptionAdded;
poseProfilesList.onRemoveCallback += PoseProfilesList_OnConfigurationOptionRemoved;

handPoseAnimationSpeed = serializedObject.FindProperty(nameof(handPoseAnimationSpeed));
}

Expand All @@ -45,7 +58,8 @@ public override void OnInspectorGUI()

EditorGUILayout.Space();

showSimulatedHandTrackingSettings = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showSimulatedHandTrackingSettings, SimulatedHandSettingsFoldoutHeader, true);
showSimulatedHandTrackingSettings = EditorGUILayoutExtensions.FoldoutWithBoldLabel(showSimulatedHandTrackingSettings, SimulatedHandSettingsFoldoutHeader);

if (showSimulatedHandTrackingSettings)
{
EditorGUI.indentLevel++;
Expand All @@ -64,9 +78,8 @@ public override void OnInspectorGUI()
EditorGUILayout.Space();
EditorGUI.indentLevel--;

EditorGUILayout.LabelField("Tracked Hand Poses");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(trackedPoses, true);
poseProfilesList.DoLayoutList();
EditorGUILayout.Space();
EditorGUI.indentLevel--;

Expand All @@ -81,5 +94,50 @@ public override void OnInspectorGUI()
serializedObject.ApplyModifiedProperties();
}
}

private void PoseProfilesList_DrawHeaderCallback(Rect rect)
{
EditorGUI.LabelField(rect, "Tracked Hand Poses");
}

private void PoseProfilesList_DrawConfigurationOptionElement(Rect rect, int index, bool isActive, bool isFocused)
{
if (isFocused)
{
currentlySelectedPoseElement = index;
}

rect.height = EditorGUIUtility.singleLineHeight;
rect.y += 3;
var poseDataProperty = trackedPoses.GetArrayElementAtIndex(index);
var selectedPoseData = EditorGUI.ObjectField(rect, poseDataProperty.objectReferenceValue, typeof(HandControllerPoseProfile), false) as HandControllerPoseProfile;

if (selectedPoseData != null)
{
selectedPoseData.ParentProfile = ThisProfile;
}

poseDataProperty.objectReferenceValue = selectedPoseData;
}

private void PoseProfilesList_OnConfigurationOptionAdded(ReorderableList list)
{
trackedPoses.arraySize += 1;
var index = trackedPoses.arraySize - 1;

var mappingProfileProperty = trackedPoses.GetArrayElementAtIndex(index);
mappingProfileProperty.objectReferenceValue = null;
serializedObject.ApplyModifiedProperties();
}

private void PoseProfilesList_OnConfigurationOptionRemoved(ReorderableList list)
{
if (currentlySelectedPoseElement >= 0)
{
trackedPoses.DeleteArrayElementAtIndex(currentlySelectedPoseElement);
}

serializedObject.ApplyModifiedProperties();
}
}
}
0