Skip to content

Commit 25e26e7

Browse files
Updated inspector and added roadmap for future gltf additions
1 parent b20052f commit 25e26e7

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

Assets/MixedRealityToolkit/_Core/Devices/BaseController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ private void TryRenderControllerModel(Type controllerType)
202202
}
203203
}
204204

205+
// TODO: add default model assignment here if no prefabs were found, or if settings specified to use them.
206+
205207
// If we've got a controller model prefab, then place it in the scene.
206208
if (controllerModel != null)
207209
{

Assets/MixedRealityToolkit/_Core/Inspectors/Profiles/MixedRealityControllerVisualizationProfileInspector.cs

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public override void OnInspectorGUI()
8484

8585
EditorGUILayout.Space();
8686
EditorGUILayout.LabelField("Controller Visualizations", EditorStyles.boldLabel);
87-
EditorGUILayout.HelpBox("Define all the custom controller visualizations you'd like to use for each controller type when they're rendered in the scene.", MessageType.Info);
87+
EditorGUILayout.HelpBox("Define all the custom controller visualizations you'd like to use for each controller type when they're rendered in the scene.\n\n" +
88+
"Global settings are the default fallback, and any specific controller definitions take precedence.", MessageType.Info);
8889
serializedObject.Update();
8990

9091
if (MixedRealityPreferences.LockProfiles && !((BaseMixedRealityProfile)target).IsCustomProfile)
@@ -97,19 +98,25 @@ public override void OnInspectorGUI()
9798

9899
if (renderMotionControllers.boolValue)
99100
{
101+
var leftHandModelPrefab = globalLeftHandModel.objectReferenceValue as GameObject;
102+
var rightHandModelPrefab = globalRightHandModel.objectReferenceValue as GameObject;
103+
100104
EditorGUILayout.PropertyField(controllerVisualizationType);
101105
EditorGUILayout.PropertyField(useDefaultModels);
102106

107+
if (useDefaultModels.boolValue && (leftHandModelPrefab != null || rightHandModelPrefab != null))
108+
{
109+
EditorGUILayout.HelpBox("When default models are used, the global left and right hand models will only be used if the default models cannot be loaded from the driver.", MessageType.Warning);
110+
}
111+
103112
EditorGUI.BeginChangeCheck();
104-
var leftHandModelPrefab = globalLeftHandModel.objectReferenceValue as GameObject;
105113
leftHandModelPrefab = EditorGUILayout.ObjectField(new GUIContent(globalLeftHandModel.displayName, "Note: If the default model is not found, the fallback is the global left hand model."), leftHandModelPrefab, typeof(GameObject), false) as GameObject;
106114

107115
if (EditorGUI.EndChangeCheck() && CheckVisualizer(leftHandModelPrefab))
108116
{
109117
globalLeftHandModel.objectReferenceValue = leftHandModelPrefab;
110118
}
111119

112-
var rightHandModelPrefab = globalRightHandModel.objectReferenceValue as GameObject;
113120
EditorGUI.BeginChangeCheck();
114121
rightHandModelPrefab = EditorGUILayout.ObjectField(new GUIContent(globalRightHandModel.displayName, "Note: If the default model is not found, the fallback is the global right hand model."), rightHandModelPrefab, typeof(GameObject), false) as GameObject;
115122

@@ -155,7 +162,13 @@ private void RenderControllerList(SerializedProperty controllerList)
155162
EditorGUIUtility.fieldWidth = 64f;
156163
var controllerSetting = controllerList.GetArrayElementAtIndex(i);
157164
var mixedRealityControllerMappingDescription = controllerSetting.FindPropertyRelative("description");
158-
mixedRealityControllerMappingDescription.stringValue = thisProfile.ControllerVisualizationSettings[i].ControllerType.Type.Name.ToProperCase();
165+
bool hasValidType = thisProfile.ControllerVisualizationSettings[i].ControllerType != null &&
166+
thisProfile.ControllerVisualizationSettings[i].ControllerType.Type != null;
167+
if (hasValidType)
168+
{
169+
mixedRealityControllerMappingDescription.stringValue = thisProfile.ControllerVisualizationSettings[i].ControllerType.Type.Name.ToProperCase();
170+
}
171+
159172
serializedObject.ApplyModifiedProperties();
160173
var mixedRealityControllerHandedness = controllerSetting.FindPropertyRelative("handedness");
161174
EditorGUILayout.LabelField($"{mixedRealityControllerMappingDescription.stringValue.ToProperCase()} {((Handedness)mixedRealityControllerHandedness.intValue).ToString().ToProperCase()} Hand");
@@ -177,6 +190,11 @@ private void RenderControllerList(SerializedProperty controllerList)
177190

178191
EditorGUILayout.PropertyField(controllerSetting.FindPropertyRelative("controllerType"));
179192

193+
if (!hasValidType)
194+
{
195+
EditorGUILayout.HelpBox("A controller type must be defined!", MessageType.Error);
196+
}
197+
180198
var handednessValue = mixedRealityControllerHandedness.intValue - 1;
181199

182200
// Reset in case it was set to something other than left or right.
@@ -190,11 +208,17 @@ private void RenderControllerList(SerializedProperty controllerList)
190208
mixedRealityControllerHandedness.intValue = handednessValue + 1;
191209
}
192210

193-
EditorGUILayout.PropertyField(controllerSetting.FindPropertyRelative("useDefaultModel"));
194-
195211
var overrideModel = controllerSetting.FindPropertyRelative("overrideModel");
196-
197212
var overrideModelPrefab = overrideModel.objectReferenceValue as GameObject;
213+
214+
var controllerUseDefaultModelOverride = controllerSetting.FindPropertyRelative("useDefaultModel");
215+
EditorGUILayout.PropertyField(controllerUseDefaultModelOverride);
216+
217+
if (controllerUseDefaultModelOverride.boolValue && overrideModelPrefab != null)
218+
{
219+
EditorGUILayout.HelpBox("When default model is used, the override model will only be used if the default model cannot be loaded from the driver.", MessageType.Warning);
220+
}
221+
198222
EditorGUI.BeginChangeCheck();
199223
overrideModelPrefab = EditorGUILayout.ObjectField(new GUIContent(overrideModel.displayName, "If no override model is set, the global model is used."), overrideModelPrefab, typeof(GameObject), false) as GameObject;
200224

@@ -211,7 +235,8 @@ private bool CheckVisualizer(GameObject modelPrefab)
211235
{
212236
if (modelPrefab == null) { return true; }
213237

214-
if (PrefabUtility.GetPrefabType(modelPrefab) != PrefabType.Prefab)
238+
var prefabType = PrefabUtility.GetPrefabType(modelPrefab);
239+
if (prefabType != PrefabType.Prefab)
215240
{
216241
Debug.LogWarning("Assigned GameObject must be a prefab");
217242
return false;
@@ -226,6 +251,10 @@ private bool CheckVisualizer(GameObject modelPrefab)
226251
{
227252
modelPrefab.AddComponent(thisProfile.ControllerVisualizationType.Type);
228253
}
254+
else
255+
{
256+
Debug.LogError("No controller visualization type specified!");
257+
}
229258
}
230259
else if (componentList.Length == 1)
231260
{

0 commit comments

Comments
 (0)