Skip to content

Commit 759f91d

Browse files
committed
Add the rest of the custom inspectors
1 parent 194d61d commit 759f91d

File tree

4 files changed

+130
-0
lines changed

4 files changed

+130
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
using Microsoft.MixedReality.Toolkit.SDK.Utilities.Solvers;
5+
using UnityEditor;
6+
using UnityEngine;
7+
8+
namespace Microsoft.MixedReality.Toolkit.SDK.Inspectors.Utilities.Solvers
9+
{
10+
[CustomEditor(typeof(ControllerFinder))]
11+
public abstract class ControllerFinderInspector : Editor
12+
{
13+
private SerializedProperty handednessProperty;
14+
15+
protected virtual void OnEnable()
16+
{
17+
handednessProperty = serializedObject.FindProperty("handedness");
18+
}
19+
20+
public override void OnInspectorGUI()
21+
{
22+
serializedObject.Update();
23+
24+
EditorGUILayout.Space();
25+
EditorGUILayout.LabelField("Controller Options", new GUIStyle("Label") { fontStyle = FontStyle.Bold });
26+
EditorGUILayout.Space();
27+
EditorGUI.indentLevel++;
28+
29+
EditorGUILayout.PropertyField(handednessProperty);
30+
31+
EditorGUI.indentLevel--;
32+
serializedObject.ApplyModifiedProperties();
33+
}
34+
}
35+
}

Assets/MixedRealityToolkit-SDK/Inspectors/Utilities/Solvers/ControllerFinderInspector.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
using Microsoft.MixedReality.Toolkit.Core.Definitions.Utilities;
5+
using Microsoft.MixedReality.Toolkit.SDK.Utilities.Solvers;
6+
using UnityEditor;
7+
using UnityEngine;
8+
9+
namespace Microsoft.MixedReality.Toolkit.SDK.Inspectors.Utilities.Solvers
10+
{
11+
[CustomEditor(typeof(SolverHandler))]
12+
[CanEditMultipleObjects]
13+
public class SolverHandlerInspector : ControllerFinderInspector
14+
{
15+
private SerializedProperty trackedObjectProperty;
16+
private SerializedProperty transformTargetProperty;
17+
private SerializedProperty additionalOffsetProperty;
18+
private SerializedProperty additionalRotationProperty;
19+
private SerializedProperty updateSolversProperty;
20+
private SolverHandler solverHandler;
21+
private readonly GUIContent trackedTransformGUIContent = new GUIContent("Tracked Transform");
22+
23+
protected override void OnEnable()
24+
{
25+
base.OnEnable();
26+
27+
trackedObjectProperty = serializedObject.FindProperty("trackedObjectToReference");
28+
transformTargetProperty = serializedObject.FindProperty("transformTarget");
29+
additionalOffsetProperty = serializedObject.FindProperty("additionalOffset");
30+
additionalRotationProperty = serializedObject.FindProperty("additionalRotation");
31+
updateSolversProperty = serializedObject.FindProperty("updateSolvers");
32+
33+
solverHandler = target as SolverHandler;
34+
}
35+
36+
public override void OnInspectorGUI()
37+
{
38+
serializedObject.Update();
39+
EditorGUILayout.Space();
40+
41+
bool trackedObjectChanged = false;
42+
43+
if (transformTargetProperty.objectReferenceValue == null || Application.isPlaying)
44+
{
45+
EditorGUI.BeginChangeCheck();
46+
EditorGUILayout.PropertyField(trackedObjectProperty);
47+
trackedObjectChanged = EditorGUI.EndChangeCheck();
48+
}
49+
50+
EditorGUILayout.PropertyField(transformTargetProperty, trackedTransformGUIContent);
51+
52+
EditorGUI.BeginChangeCheck();
53+
EditorGUILayout.PropertyField(additionalOffsetProperty);
54+
EditorGUILayout.PropertyField(additionalRotationProperty);
55+
bool additionalOffsetChanged = EditorGUI.EndChangeCheck();
56+
57+
EditorGUILayout.PropertyField(updateSolversProperty);
58+
59+
serializedObject.ApplyModifiedProperties();
60+
61+
if (Application.isPlaying && trackedObjectChanged)
62+
{
63+
solverHandler.RefreshTrackedObject();
64+
}
65+
66+
if (Application.isPlaying && additionalOffsetChanged)
67+
{
68+
solverHandler.AdditionalOffset = additionalOffsetProperty.vector3Value;
69+
solverHandler.AdditionalRotation = additionalRotationProperty.vector3Value;
70+
}
71+
}
72+
}
73+
}

Assets/MixedRealityToolkit-SDK/Inspectors/Utilities/Solvers/SolverHandlerInspector.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)