@@ -18,9 +18,9 @@ public class MixedRealityInputActionRulesInspector : MixedRealityBaseConfigurati
1818 {
1919 private static readonly GUIContent RuleAddButtonContent = new GUIContent ( "+ Add a New Rule Definition" ) ;
2020 private static readonly GUIContent RuleMinusButtonContent = new GUIContent ( "-" , "Remove Rule Definition" ) ;
21- private static readonly GUIContent BaseActionContent = new GUIContent ( "Base Input Action" , "The Action that will raise new actions based on the criteria met" ) ;
22- private static readonly GUIContent RuleActionContent = new GUIContent ( "Rule Input Action" , "The Action that will be raised when the criteria is met" ) ;
23- private static readonly GUIContent CriteriaContent = new GUIContent ( "Action Criteria" , "The Criteria that must be met in order to raise the new Action" ) ;
21+ private static readonly GUIContent BaseActionContent = new GUIContent ( "Base Input Action: " , "The Action that will raise new actions based on the criteria met" ) ;
22+ private static readonly GUIContent RuleActionContent = new GUIContent ( "Rule Input Action: " , "The Action that will be raised when the criteria is met" ) ;
23+ private static readonly GUIContent CriteriaContent = new GUIContent ( "Action Criteria: " , "The Criteria that must be met in order to raise the new Action" ) ;
2424
2525 private SerializedProperty inputActionRulesDigital ;
2626 private SerializedProperty inputActionRulesSingleAxis ;
@@ -220,8 +220,10 @@ private static void GetCompatibleActions(MixedRealityInputAction baseAction)
220220 . ToArray ( ) ;
221221 }
222222
223- private void RenderCriteriaField ( MixedRealityInputAction action )
223+ private void RenderCriteriaField ( MixedRealityInputAction action , SerializedProperty criteriaValue = null )
224224 {
225+ var isWideMode = EditorGUIUtility . wideMode ;
226+ EditorGUIUtility . wideMode = true ;
225227 if ( action != MixedRealityInputAction . None )
226228 {
227229 switch ( action . AxisConstraint )
@@ -230,30 +232,142 @@ private void RenderCriteriaField(MixedRealityInputAction action)
230232 EditorGUILayout . HelpBox ( "Base rule must have a valid axis constraint." , MessageType . Warning ) ;
231233 break ;
232234 case AxisType . Digital :
233- currentBoolCriteria = EditorGUILayout . Toggle ( CriteriaContent , currentBoolCriteria ) ;
235+ EditorGUILayout . BeginHorizontal ( ) ;
236+ EditorGUILayout . LabelField ( CriteriaContent , GUILayout . Width ( 128 ) ) ;
237+ EditorGUI . BeginChangeCheck ( ) ;
238+ var boolValue = EditorGUILayout . Toggle ( GUIContent . none , criteriaValue ? . boolValue ?? currentBoolCriteria , GUILayout . Width ( 64 ) , GUILayout . ExpandWidth ( true ) ) ;
239+
240+ if ( EditorGUI . EndChangeCheck ( ) )
241+ {
242+ if ( criteriaValue != null )
243+ {
244+ criteriaValue . boolValue = boolValue ;
245+ }
246+ else
247+ {
248+ currentBoolCriteria = boolValue ;
249+ }
250+ }
251+
252+ EditorGUILayout . EndHorizontal ( ) ;
234253 break ;
235254 case AxisType . SingleAxis :
236- currentSingleAxisCriteria = EditorGUILayout . FloatField ( CriteriaContent , currentSingleAxisCriteria ) ;
255+ EditorGUILayout . BeginHorizontal ( ) ;
256+ EditorGUILayout . LabelField ( CriteriaContent , GUILayout . Width ( 128 ) ) ;
257+ EditorGUI . BeginChangeCheck ( ) ;
258+ var floatValue = EditorGUILayout . FloatField ( GUIContent . none , criteriaValue ? . floatValue ?? currentSingleAxisCriteria , GUILayout . Width ( 64 ) , GUILayout . ExpandWidth ( true ) ) ;
259+
260+ if ( EditorGUI . EndChangeCheck ( ) )
261+ {
262+ if ( criteriaValue != null )
263+ {
264+ criteriaValue . floatValue = floatValue ;
265+ }
266+ else
267+ {
268+ currentSingleAxisCriteria = floatValue ;
269+ }
270+ }
271+
272+ EditorGUILayout . EndHorizontal ( ) ;
237273 break ;
238274 case AxisType . DualAxis :
239- currentDualAxisCriteria = EditorGUILayout . Vector2Field ( CriteriaContent , currentDualAxisCriteria ) ;
275+ EditorGUILayout . LabelField ( CriteriaContent , GUILayout . Width ( 128 ) ) ;
276+ EditorGUI . indentLevel ++ ;
277+ EditorGUI . BeginChangeCheck ( ) ;
278+ var dualAxisValue = EditorGUILayout . Vector2Field ( "Position" , criteriaValue ? . vector2Value ?? currentDualAxisCriteria , GUILayout . Width ( 64 ) , GUILayout . ExpandWidth ( true ) ) ;
279+
280+ if ( EditorGUI . EndChangeCheck ( ) )
281+ {
282+ if ( criteriaValue != null )
283+ {
284+ criteriaValue . vector2Value = dualAxisValue ;
285+ }
286+ else
287+ {
288+ currentDualAxisCriteria = dualAxisValue ;
289+ }
290+ }
291+
292+ EditorGUI . indentLevel -- ;
240293 break ;
241294 case AxisType . ThreeDofPosition :
242- currentVectorCriteria = EditorGUILayout . Vector3Field ( CriteriaContent , currentVectorCriteria ) ;
295+ EditorGUILayout . LabelField ( CriteriaContent , GUILayout . Width ( 128 ) ) ;
296+ EditorGUI . indentLevel ++ ;
297+ EditorGUI . BeginChangeCheck ( ) ;
298+ var positionValue = EditorGUILayout . Vector3Field ( "Position" , criteriaValue ? . vector3Value ?? currentVectorCriteria , GUILayout . ExpandWidth ( true ) ) ;
299+
300+ if ( EditorGUI . EndChangeCheck ( ) )
301+ {
302+ if ( criteriaValue != null )
303+ {
304+ criteriaValue . vector3Value = positionValue ;
305+ }
306+ else
307+ {
308+ currentVectorCriteria = positionValue ;
309+ }
310+ }
311+
312+ EditorGUI . indentLevel -- ;
243313 break ;
244314 case AxisType . ThreeDofRotation :
245- currentQuaternionCriteria . eulerAngles = EditorGUILayout . Vector3Field ( CriteriaContent , currentQuaternionCriteria . eulerAngles ) ;
315+ EditorGUILayout . LabelField ( CriteriaContent , GUILayout . Width ( 128 ) ) ;
316+ EditorGUI . indentLevel ++ ;
317+ EditorGUI . BeginChangeCheck ( ) ;
318+ var rotationValue = EditorGUILayout . Vector3Field ( "Rotation" , criteriaValue ? . quaternionValue . eulerAngles ?? currentQuaternionCriteria . eulerAngles , GUILayout . ExpandWidth ( true ) ) ;
319+
320+ if ( EditorGUI . EndChangeCheck ( ) )
321+ {
322+ if ( criteriaValue != null )
323+ {
324+ criteriaValue . quaternionValue = Quaternion . Euler ( rotationValue ) ;
325+ }
326+ else
327+ {
328+ currentQuaternionCriteria = Quaternion . Euler ( rotationValue ) ;
329+ }
330+ }
331+
332+ EditorGUI . indentLevel -- ;
246333 break ;
247334 case AxisType . SixDof :
248- EditorGUILayout . LabelField ( CriteriaContent ) ;
335+ EditorGUILayout . LabelField ( CriteriaContent , GUILayout . Width ( 128 ) ) ;
249336 EditorGUI . indentLevel ++ ;
250- currentPoseCriteria . Position = EditorGUILayout . Vector3Field ( "Position" , currentPoseCriteria . Position ) ;
251- Quaternion rotation = currentPoseCriteria . Rotation ;
252- rotation . eulerAngles = EditorGUILayout . Vector3Field ( "Rotation" , rotation . eulerAngles ) ;
253- currentPoseCriteria . Rotation = rotation ;
337+
338+ var posePosition = currentPoseCriteria . Position ;
339+ var poseRotation = currentPoseCriteria . Rotation ;
340+
341+ if ( criteriaValue != null )
342+ {
343+ posePosition = criteriaValue . FindPropertyRelative ( "position" ) . vector3Value ;
344+ poseRotation = criteriaValue . FindPropertyRelative ( "rotation" ) . quaternionValue ;
345+ }
346+
347+ EditorGUI . BeginChangeCheck ( ) ;
348+ posePosition = EditorGUILayout . Vector3Field ( "Position" , posePosition ) ;
349+
350+ poseRotation . eulerAngles = EditorGUILayout . Vector3Field ( "Rotation" , poseRotation . eulerAngles ) ;
351+
352+ if ( EditorGUI . EndChangeCheck ( ) )
353+ {
354+ if ( criteriaValue != null )
355+ {
356+ criteriaValue . FindPropertyRelative ( "position" ) . vector3Value = posePosition ;
357+ criteriaValue . FindPropertyRelative ( "rotation" ) . quaternionValue = poseRotation ;
358+ }
359+ else
360+ {
361+ currentPoseCriteria . Position = posePosition ;
362+ currentPoseCriteria . Rotation = poseRotation ;
363+ }
364+ }
365+
254366 EditorGUI . indentLevel -- ;
255367 break ;
256368 }
369+
370+ EditorGUIUtility . wideMode = isWideMode ;
257371 }
258372 }
259373
@@ -318,13 +432,17 @@ private void AddRule()
318432 ruleActionConstraint . intValue = ( int ) currentRuleAction . AxisConstraint ;
319433 }
320434
321- private int RenderBaseInputAction ( int baseActionId , out MixedRealityInputAction action )
435+ private int RenderBaseInputAction ( int baseActionId , out MixedRealityInputAction action , bool isLocked = false )
322436 {
323437 action = MixedRealityInputAction . None ;
324438 EditorGUILayout . BeginHorizontal ( ) ;
325- EditorGUILayout . LabelField ( BaseActionContent ) ;
439+ EditorGUILayout . LabelField ( BaseActionContent , GUILayout . Width ( 128 ) ) ;
326440 EditorGUI . BeginChangeCheck ( ) ;
327- baseActionId = EditorGUILayout . IntPopup ( baseActionId , baseActionLabels , baseActionIds ) ;
441+
442+ if ( ! isLocked )
443+ {
444+ baseActionId = EditorGUILayout . IntPopup ( baseActionId , baseActionLabels , baseActionIds , GUILayout . ExpandWidth ( true ) ) ;
445+ }
328446
329447 for ( int i = 0 ; i < MixedRealityManager . Instance . ActiveProfile . InputSystemProfile . InputActionsProfile . InputActions . Length ; i ++ )
330448 {
@@ -339,6 +457,11 @@ private int RenderBaseInputAction(int baseActionId, out MixedRealityInputAction
339457 GetCompatibleActions ( action ) ;
340458 }
341459
460+ if ( isLocked )
461+ {
462+ EditorGUILayout . LabelField ( action . Description , EditorStyles . boldLabel , GUILayout . ExpandWidth ( true ) ) ;
463+ }
464+
342465 EditorGUILayout . EndHorizontal ( ) ;
343466 return baseActionId ;
344467 }
@@ -347,9 +470,9 @@ private int RenderRuleInputAction(int ruleActionId, out MixedRealityInputAction
347470 {
348471 action = MixedRealityInputAction . None ;
349472 EditorGUILayout . BeginHorizontal ( ) ;
350- EditorGUILayout . LabelField ( RuleActionContent ) ;
473+ EditorGUILayout . LabelField ( RuleActionContent , GUILayout . Width ( 128 ) ) ;
351474 EditorGUI . BeginChangeCheck ( ) ;
352- ruleActionId = EditorGUILayout . IntPopup ( ruleActionId , ruleActionLabels , ruleActionIds ) ;
475+ ruleActionId = EditorGUILayout . IntPopup ( ruleActionId , ruleActionLabels , ruleActionIds , GUILayout . ExpandWidth ( true ) ) ;
353476
354477 for ( int i = 0 ; i < MixedRealityManager . Instance . ActiveProfile . InputSystemProfile . InputActionsProfile . InputActions . Length ; i ++ )
355478 {
@@ -397,18 +520,19 @@ private void RenderList(SerializedProperty list, bool[] foldouts)
397520 EditorGUI . indentLevel ++ ;
398521
399522 MixedRealityInputAction newBaseAction ;
400- baseActionId . intValue = RenderBaseInputAction ( baseActionId . intValue , out newBaseAction ) ;
523+ baseActionId . intValue = RenderBaseInputAction ( baseActionId . intValue , out newBaseAction , true ) ;
401524 baseActionDescription . stringValue = newBaseAction . Description ;
402525 baseActionConstraint . intValue = ( int ) newBaseAction . AxisConstraint ;
403526
404- if ( baseActionId . intValue == ruleActionId . intValue || newBaseAction == MixedRealityInputAction . None )
527+ if ( baseActionId . intValue == ruleActionId . intValue || newBaseAction == MixedRealityInputAction . None || baseActionConstraint . intValue != ruleActionConstraint . intValue )
405528 {
529+ criteria . Reset ( ) ;
406530 ruleActionId . intValue = ( int ) MixedRealityInputAction . None . Id ;
407531 ruleActionDescription . stringValue = MixedRealityInputAction . None . Description ;
408532 ruleActionConstraint . intValue = ( int ) MixedRealityInputAction . None . AxisConstraint ;
409533 }
410534
411- EditorGUILayout . PropertyField ( criteria , CriteriaContent ) ;
535+ RenderCriteriaField ( newBaseAction , criteria ) ;
412536
413537 MixedRealityInputAction newRuleAction ;
414538 ruleActionId . intValue = RenderRuleInputAction ( ruleActionId . intValue , out newRuleAction ) ;
0 commit comments