|
4 | 4 | // |
5 | 5 |
|
6 | 6 | using Microsoft.MixedReality.Toolkit.Experimental.UI; |
| 7 | +using Microsoft.MixedReality.Toolkit.UI; |
7 | 8 | using Microsoft.MixedReality.Toolkit.Utilities; |
| 9 | +using System; |
| 10 | +using System.Linq; |
8 | 11 | using UnityEditor; |
9 | 12 | using UnityEngine; |
| 13 | +using UnityEngine.UI; |
10 | 14 |
|
11 | 15 | namespace Microsoft.MixedReality.Toolkit.Experimental.Editor |
12 | 16 | { |
@@ -41,6 +45,7 @@ public class ObjectManipulatorInspector : UnityEditor.Editor |
41 | 45 |
|
42 | 46 | bool oneHandedFoldout = true; |
43 | 47 | bool twoHandedFoldout = true; |
| 48 | + bool constraintsFoldout = true; |
44 | 49 | bool physicsFoldout = true; |
45 | 50 | bool smoothingFoldout = true; |
46 | 51 | bool eventsFoldout = true; |
@@ -120,6 +125,45 @@ public override void OnInspectorGUI() |
120 | 125 | var mh = (ObjectManipulator)target; |
121 | 126 | var rb = mh.HostTransform.GetComponent<Rigidbody>(); |
122 | 127 |
|
| 128 | + EditorGUILayout.Space(); |
| 129 | + constraintsFoldout = EditorGUILayout.Foldout(constraintsFoldout, "Constraints", true); |
| 130 | + |
| 131 | + if (constraintsFoldout) |
| 132 | + { |
| 133 | + if (EditorGUILayout.DropdownButton(new GUIContent("Add Constraint"), FocusType.Keyboard)) |
| 134 | + { |
| 135 | + // create the menu and add items to it |
| 136 | + GenericMenu menu = new GenericMenu(); |
| 137 | + |
| 138 | + var type = typeof(TransformConstraint); |
| 139 | + var types = AppDomain.CurrentDomain.GetAssemblies() |
| 140 | + .SelectMany(s => s.GetTypes()) |
| 141 | + .Where(p => type.IsAssignableFrom(p)); |
| 142 | + |
| 143 | + foreach (var derivedType in types) |
| 144 | + { |
| 145 | + menu.AddItem(new GUIContent(derivedType.Name), false, t => mh.gameObject.AddComponent((Type)t), derivedType); |
| 146 | + } |
| 147 | + |
| 148 | + menu.ShowAsContext(); |
| 149 | + } |
| 150 | + |
| 151 | + var constraints = mh.GetComponents<TransformConstraint>(); |
| 152 | + |
| 153 | + foreach (var constraint in constraints) |
| 154 | + { |
| 155 | + EditorGUILayout.BeginHorizontal(); |
| 156 | + string constraintName = constraint.GetType().Name; |
| 157 | + EditorGUILayout.LabelField(constraintName); |
| 158 | + if (GUILayout.Button("Go to component")) |
| 159 | + { |
| 160 | + Debug.Log($"Highlighting {ObjectNames.NicifyVariableName(constraintName)} (Script)"); |
| 161 | + Highlighter.Highlight("Inspector", $"{ObjectNames.NicifyVariableName(constraintName)} (Script)"); |
| 162 | + } |
| 163 | + EditorGUILayout.EndHorizontal(); |
| 164 | + } |
| 165 | + } |
| 166 | + |
123 | 167 | EditorGUILayout.Space(); |
124 | 168 | physicsFoldout = EditorGUILayout.Foldout(physicsFoldout, "Physics", true); |
125 | 169 |
|
|
0 commit comments