@@ -54,6 +54,8 @@ public class MixedRealityInputActionRulesInspector : MixedRealityBaseConfigurati
5454 private bool [ ] quaternionFoldouts ;
5555 private bool [ ] poseFoldouts ;
5656
57+ private MixedRealityInputActionRulesProfile thisProfile ;
58+
5759 private void OnEnable ( )
5860 {
5961 if ( ! CheckMixedRealityManager ( false ) ||
@@ -71,12 +73,16 @@ private void OnEnable()
7173 inputActionRulesPoseAxis = serializedObject . FindProperty ( "inputActionRulesPoseAxis" ) ;
7274
7375 baseActionLabels = MixedRealityManager . Instance . ActiveProfile . InputSystemProfile . InputActionsProfile . InputActions
76+ . Where ( action => action . AxisConstraint != AxisType . None && action . AxisConstraint != AxisType . Raw )
7477 . Select ( action => action . Description )
75- . Prepend ( "None" ) . ToArray ( ) ;
78+ . ToArray ( ) ;
7679
7780 baseActionIds = MixedRealityManager . Instance . ActiveProfile . InputSystemProfile . InputActionsProfile . InputActions
81+ . Where ( action => action . AxisConstraint != AxisType . None && action . AxisConstraint != AxisType . Raw )
7882 . Select ( action => ( int ) action . Id )
79- . Prepend ( 0 ) . ToArray ( ) ;
83+ . ToArray ( ) ;
84+
85+ thisProfile = target as MixedRealityInputActionRulesProfile ;
8086
8187 ResetCriteria ( ) ;
8288 }
@@ -128,6 +134,7 @@ public override void OnInspectorGUI()
128134 EditorGUILayout . Space ( ) ;
129135
130136 GUI . enabled = isGuiLocked &&
137+ ! RuleExists ( ) &&
131138 currentBaseAction != MixedRealityInputAction . None &&
132139 currentRuleAction != MixedRealityInputAction . None &&
133140 currentBaseAction . AxisConstraint != AxisType . None &&
@@ -157,6 +164,27 @@ public override void OnInspectorGUI()
157164 serializedObject . ApplyModifiedProperties ( ) ;
158165 }
159166
167+ private bool RuleExists ( )
168+ {
169+ switch ( currentBaseAction . AxisConstraint )
170+ {
171+ default :
172+ return false ;
173+ case AxisType . Digital :
174+ return thisProfile . InputActionRulesDigital . Any ( digitalRule => digitalRule . BaseAction == currentBaseAction && digitalRule . RuleAction == currentRuleAction ) ;
175+ case AxisType . SingleAxis :
176+ return thisProfile . InputActionRulesSingleAxis . Any ( singleAxisRule => singleAxisRule . BaseAction == currentBaseAction && singleAxisRule . RuleAction == currentRuleAction ) ;
177+ case AxisType . DualAxis :
178+ return thisProfile . InputActionRulesDualAxis . Any ( dualAxisRule => dualAxisRule . BaseAction == currentBaseAction && dualAxisRule . RuleAction == currentRuleAction ) ;
179+ case AxisType . ThreeDofPosition :
180+ return thisProfile . InputActionRulesVectorAxis . Any ( vectorAxisRule => vectorAxisRule . BaseAction == currentBaseAction && vectorAxisRule . RuleAction == currentRuleAction ) ;
181+ case AxisType . ThreeDofRotation :
182+ return thisProfile . InputActionRulesQuaternionAxis . Any ( quaternionRule => quaternionRule . BaseAction == currentBaseAction && quaternionRule . RuleAction == currentRuleAction ) ;
183+ case AxisType . SixDof :
184+ return thisProfile . InputActionRulesPoseAxis . Any ( poseRule => poseRule . BaseAction == currentBaseAction && poseRule . RuleAction == currentRuleAction ) ;
185+ }
186+ }
187+
160188 private void ResetCriteria ( )
161189 {
162190 selectedBaseActionId = 0 ;
@@ -183,12 +211,12 @@ private static void GetCompatibleActions(MixedRealityInputAction baseAction)
183211 ruleActionLabels = MixedRealityManager . Instance . ActiveProfile . InputSystemProfile . InputActionsProfile . InputActions
184212 . Where ( inputAction => inputAction . AxisConstraint == baseAction . AxisConstraint && inputAction . Id != baseAction . Id )
185213 . Select ( action => action . Description )
186- . Prepend ( "None" ) . ToArray ( ) ;
214+ . ToArray ( ) ;
187215
188216 ruleActionIds = MixedRealityManager . Instance . ActiveProfile . InputSystemProfile . InputActionsProfile . InputActions
189217 . Where ( inputAction => inputAction . AxisConstraint == baseAction . AxisConstraint && inputAction . Id != baseAction . Id )
190218 . Select ( action => ( int ) action . Id )
191- . Prepend ( 0 ) . ToArray ( ) ;
219+ . ToArray ( ) ;
192220 }
193221
194222 private void RenderCriteriaField ( MixedRealityInputAction action )
@@ -198,11 +226,7 @@ private void RenderCriteriaField(MixedRealityInputAction action)
198226 switch ( action . AxisConstraint )
199227 {
200228 default :
201- case AxisType . None :
202- EditorGUILayout . HelpBox ( "Base rule must have an axis constraint." , MessageType . Warning ) ;
203- break ;
204- case AxisType . Raw :
205- EditorGUILayout . HelpBox ( "Base rule's axis constraint is Raw. It's not possible to set this value in the inspector." , MessageType . Warning ) ;
229+ EditorGUILayout . HelpBox ( "Base rule must have a valid axis constraint." , MessageType . Warning ) ;
206230 break ;
207231 case AxisType . Digital :
208232 currentBoolCriteria = EditorGUILayout . Toggle ( CriteriaContent , currentBoolCriteria ) ;
@@ -383,7 +407,7 @@ private void RenderList(SerializedProperty list, bool[] foldouts)
383407 ruleActionConstraint . intValue = ( int ) MixedRealityInputAction . None . AxisConstraint ;
384408 }
385409
386- EditorGUILayout . PropertyField ( criteria ) ;
410+ EditorGUILayout . PropertyField ( criteria , CriteriaContent ) ;
387411
388412 MixedRealityInputAction newRuleAction ;
389413 ruleActionId . intValue = RenderRuleInputAction ( ruleActionId . intValue , out newRuleAction ) ;
0 commit comments