@@ -291,6 +291,7 @@ public static List<TreeViewItemData<ActionOrBindingData>> GetActionsAsTreeViewDa
291291 var actionMapIndex = state . selectedActionMapIndex ;
292292 var actionMaps = state . serializedObject . FindProperty ( nameof ( InputActionAsset . m_ActionMaps ) ) ;
293293
294+ var controlSchemes = state . serializedObject . FindProperty ( nameof ( InputActionAsset . m_ControlSchemes ) ) ;
294295 var actionMap = actionMapIndex == - 1 || actionMaps . arraySize <= 0 ?
295296 null : actionMaps . GetArrayElementAtIndex ( actionMapIndex ) ;
296297
@@ -323,10 +324,14 @@ public static List<TreeViewItemData<ActionOrBindingData>> GetActionsAsTreeViewDa
323324 var nextBinding = actionBindings [ ++ i ] ;
324325 while ( nextBinding . isPartOfComposite )
325326 {
326- var name = GetHumanReadableCompositeName ( nextBinding , state . selectedControlScheme , state . selectedControlSchemeIndex ) ;
327-
328- compositeItems . Add ( new TreeViewItemData < ActionOrBindingData > ( id ++ ,
329- new ActionOrBindingData ( false , name , actionMapIndex , false , GetControlLayout ( nextBinding . path ) , nextBinding . indexOfBinding ) ) ) ;
327+ var isVisible = ShouldBindingBeVisible ( nextBinding , state . selectedControlScheme ) ;
328+ if ( isVisible )
329+ {
330+ var name = GetHumanReadableCompositeName ( nextBinding , state . selectedControlScheme , controlSchemes ) ;
331+ compositeItems . Add ( new TreeViewItemData < ActionOrBindingData > ( id ++ ,
332+ new ActionOrBindingData ( false , name , actionMapIndex , false ,
333+ GetControlLayout ( nextBinding . path ) , nextBinding . indexOfBinding ) ) ) ;
334+ }
330335
331336 if ( ++ i >= actionBindings . Count )
332337 break ;
@@ -340,9 +345,11 @@ public static List<TreeViewItemData<ActionOrBindingData>> GetActionsAsTreeViewDa
340345 }
341346 else
342347 {
343- bindingItems . Add ( new TreeViewItemData < ActionOrBindingData > ( id ++ ,
344- new ActionOrBindingData ( false , GetHumanReadableBindingName ( serializedInputBinding , state . selectedControlSchemeIndex , state . selectedControlScheme ) , actionMapIndex ,
345- false , GetControlLayout ( serializedInputBinding . path ) , serializedInputBinding . indexOfBinding ) ) ) ;
348+ var isVisible = ShouldBindingBeVisible ( serializedInputBinding , state . selectedControlScheme ) ;
349+ if ( isVisible )
350+ bindingItems . Add ( new TreeViewItemData < ActionOrBindingData > ( id ++ ,
351+ new ActionOrBindingData ( false , GetHumanReadableBindingName ( serializedInputBinding , state . selectedControlScheme , controlSchemes ) , actionMapIndex ,
352+ false , GetControlLayout ( serializedInputBinding . path ) , serializedInputBinding . indexOfBinding ) ) ) ;
346353 }
347354 }
348355 actionItems . Add ( new TreeViewItemData < ActionOrBindingData > ( id ++ ,
@@ -351,28 +358,42 @@ public static List<TreeViewItemData<ActionOrBindingData>> GetActionsAsTreeViewDa
351358 return actionItems ;
352359 }
353360
354- private static string GetHumanReadableBindingName ( SerializedInputBinding serializedInputBinding , int currentControlSchemeIndex , InputControlScheme ? currentControlScheme )
361+ private static string GetHumanReadableBindingName ( SerializedInputBinding serializedInputBinding , InputControlScheme ? currentControlScheme , SerializedProperty allControlSchemes )
355362 {
356363 var name = InputControlPath . ToHumanReadableString ( serializedInputBinding . path ) ;
357364 if ( String . IsNullOrEmpty ( name ) )
358365 name = "<No Binding>" ;
359- if ( ! IsBindingPartOfCurrentControlScheme ( serializedInputBinding , currentControlScheme , currentControlSchemeIndex ) )
366+ if ( IsBindingAssignedToNoControlSchemes ( serializedInputBinding , allControlSchemes , currentControlScheme ) )
360367 name += " {GLOBAL}" ;
361368 return name ;
362369 }
363370
364- private static bool IsBindingPartOfCurrentControlScheme ( SerializedInputBinding serializedInputBinding , InputControlScheme ? currentControlScheme , int currentControlSchemeIndex )
371+ private static bool IsBindingAssignedToNoControlSchemes ( SerializedInputBinding serializedInputBinding , SerializedProperty allControlSchemes , InputControlScheme ? currentControlScheme )
365372 {
366- if ( currentControlScheme . HasValue && currentControlSchemeIndex >= 0 )
367- return serializedInputBinding . controlSchemes . Contains ( currentControlScheme . Value . name ) ;
373+ if ( allControlSchemes . arraySize <= 0 || ! currentControlScheme . HasValue || string . IsNullOrEmpty ( currentControlScheme . Value . name ) )
374+ return false ;
375+ if ( serializedInputBinding . controlSchemes . Length <= 0 )
376+ return true ;
377+ return false ;
378+ }
368379
380+ private static bool ShouldBindingBeVisible ( SerializedInputBinding serializedInputBinding , InputControlScheme ? currentControlScheme )
381+ {
382+ if ( currentControlScheme . HasValue && ! string . IsNullOrEmpty ( currentControlScheme . Value . name ) )
383+ {
384+ //if binding is global (not assigned to any control scheme) show always
385+ if ( serializedInputBinding . controlSchemes . Length <= 0 )
386+ return true ;
387+ return serializedInputBinding . controlSchemes . Contains ( currentControlScheme . Value . name ) ;
388+ }
389+ //if no control scheme selected then show all bindings
369390 return true ;
370391 }
371392
372- internal static string GetHumanReadableCompositeName ( SerializedInputBinding binding , InputControlScheme ? currentControlScheme , int currentControlSchemeIndex )
393+ internal static string GetHumanReadableCompositeName ( SerializedInputBinding binding , InputControlScheme ? currentControlScheme , SerializedProperty allControlSchemes )
373394 {
374395 return $ "{ ObjectNames . NicifyVariableName ( binding . name ) } : " +
375- $ "{ GetHumanReadableBindingName ( binding , currentControlSchemeIndex , currentControlScheme ) } ";
396+ $ "{ GetHumanReadableBindingName ( binding , currentControlScheme , allControlSchemes ) } ";
376397 }
377398
378399 private static string GetControlLayout ( string path )
0 commit comments