in Azure Cloud Tutorials/Assets/MRTK/Core/Inspectors/ServiceInspectors/HandJointServiceInspector.cs [32:200]
public override void DrawInspectorGUI(object target)
{
IMixedRealityHandJointService handJointService = (IMixedRealityHandJointService)target;
EditorGUILayout.LabelField("Tracking State", EditorStyles.boldLabel);
if (!Application.isPlaying)
{
GUI.color = disabledColor;
EditorGUILayout.Toggle("Left Hand Tracked", false);
EditorGUILayout.Toggle("Right Hand Tracked", false);
}
else
{
GUI.color = enabledColor;
EditorGUILayout.Toggle("Left Hand Tracked", handJointService.IsHandTracked(Handedness.Left));
EditorGUILayout.Toggle("Right Hand Tracked", handJointService.IsHandTracked(Handedness.Right));
}
GenerateHandJointLookup();
GUI.color = enabledColor;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Editor Settings", EditorStyles.boldLabel);
ShowHandPreviewInSceneView = SessionState.GetBool(ShowHandPreviewInSceneViewKey, false);
bool showHandPreviewInSceneView = EditorGUILayout.Toggle("Show Preview in Scene View", ShowHandPreviewInSceneView);
if (ShowHandPreviewInSceneView != showHandPreviewInSceneView)
{
SessionState.SetBool(ShowHandPreviewInSceneViewKey, showHandPreviewInSceneView);
}
ShowHandJointFoldout = SessionState.GetBool(ShowHandJointFoldoutKey, false);
ShowHandJointFoldout = EditorGUILayout.Foldout(ShowHandJointFoldout, "Visible Hand Joints", true);
SessionState.SetBool(ShowHandJointFoldoutKey, ShowHandJointFoldout);
if (ShowHandJointFoldout)
{
#region setting buttons
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("All"))
{
foreach (TrackedHandJoint joint in Enum.GetValues(typeof(TrackedHandJoint)))
{
if (joint == TrackedHandJoint.None)
{
continue;
}
SessionState.SetBool(showHandJointSettingKeys[joint], true);
showHandJointSettings[joint] = true;
}
}
if (GUILayout.Button("Fingers"))
{
foreach (TrackedHandJoint joint in Enum.GetValues(typeof(TrackedHandJoint)))
{
bool setting = false;
switch (joint)
{
case TrackedHandJoint.IndexTip:
case TrackedHandJoint.IndexDistalJoint:
case TrackedHandJoint.IndexKnuckle:
case TrackedHandJoint.IndexMetacarpal:
case TrackedHandJoint.IndexMiddleJoint:
case TrackedHandJoint.MiddleTip:
case TrackedHandJoint.MiddleDistalJoint:
case TrackedHandJoint.MiddleKnuckle:
case TrackedHandJoint.MiddleMetacarpal:
case TrackedHandJoint.MiddleMiddleJoint:
case TrackedHandJoint.PinkyTip:
case TrackedHandJoint.PinkyDistalJoint:
case TrackedHandJoint.PinkyKnuckle:
case TrackedHandJoint.PinkyMetacarpal:
case TrackedHandJoint.PinkyMiddleJoint:
case TrackedHandJoint.RingTip:
case TrackedHandJoint.RingDistalJoint:
case TrackedHandJoint.RingKnuckle:
case TrackedHandJoint.RingMetacarpal:
case TrackedHandJoint.RingMiddleJoint:
case TrackedHandJoint.ThumbTip:
case TrackedHandJoint.ThumbDistalJoint:
case TrackedHandJoint.ThumbMetacarpalJoint:
case TrackedHandJoint.ThumbProximalJoint:
setting = true;
break;
default:
break;
case TrackedHandJoint.None:
continue;
}
SessionState.SetBool(showHandJointSettingKeys[joint], setting);
showHandJointSettings[joint] = setting;
}
}
if (GUILayout.Button("Fingertips"))
{
foreach (TrackedHandJoint joint in Enum.GetValues(typeof(TrackedHandJoint)))
{
bool setting = false;
switch (joint)
{
case TrackedHandJoint.IndexTip:
case TrackedHandJoint.MiddleTip:
case TrackedHandJoint.PinkyTip:
case TrackedHandJoint.RingTip:
case TrackedHandJoint.ThumbTip:
setting = true;
break;
default:
break;
case TrackedHandJoint.None:
continue;
}
SessionState.SetBool(showHandJointSettingKeys[joint], setting);
showHandJointSettings[joint] = setting;
}
}
if (GUILayout.Button("None"))
{
foreach (TrackedHandJoint joint in Enum.GetValues(typeof(TrackedHandJoint)))
{
if (joint == TrackedHandJoint.None)
{
continue;
}
SessionState.SetBool(showHandJointSettingKeys[joint], false);
showHandJointSettings[joint] = false;
}
}
EditorGUILayout.EndHorizontal();
#endregion
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
foreach (TrackedHandJoint joint in Enum.GetValues(typeof(TrackedHandJoint)))
{
if (joint == TrackedHandJoint.None)
{
continue;
}
bool prevSetting = showHandJointSettings[joint];
bool newSetting = EditorGUILayout.Toggle(joint.ToString(), prevSetting);
if (newSetting != prevSetting)
{
SessionState.SetBool(showHandJointSettingKeys[joint], newSetting);
showHandJointSettings[joint] = newSetting;
}
}
EditorGUILayout.EndVertical();
}
}