@@ -26,9 +26,6 @@ internal class ActionsTreeView : ViewBase<ActionsTreeView.ViewState>
2626 private bool m_RenameOnActionAdded ;
2727 private readonly CollectionViewSelectionChangeFilter m_ActionsTreeViewSelectionChangeFilter ;
2828
29- //save TreeView element id's of individual input actions and bindings to ensure saving of expanded state
30- private Dictionary < Guid , int > m_GuidToTreeViewId ;
31-
3229 public ActionsTreeView ( VisualElement root , StateContainer stateContainer )
3330 : base ( root , stateContainer )
3431 {
@@ -38,7 +35,6 @@ public ActionsTreeView(VisualElement root, StateContainer stateContainer)
3835 m_ActionsTreeView = root . Q < TreeView > ( "actions-tree-view" ) ;
3936 //assign unique viewDataKey to store treeView states like expanded/collapsed items - make it unique to avoid conflicts with other TreeViews
4037 m_ActionsTreeView . viewDataKey = $ "InputActionTreeView_{ stateContainer . assetGUID } ";
41- m_GuidToTreeViewId = new Dictionary < Guid , int > ( ) ;
4238 m_ActionsTreeView . selectionType = UIElements . SelectionType . Single ;
4339 m_ActionsTreeView . makeItem = ( ) => new InputActionsTreeViewItem ( ) ;
4440 m_ActionsTreeView . reorderable = true ;
@@ -147,7 +143,7 @@ public ActionsTreeView(VisualElement root, StateContainer stateContainer)
147143 CreateSelector ( Selectors . GetActionsForSelectedActionMap , Selectors . GetActionMapCount ,
148144 ( _ , count , state ) =>
149145 {
150- var treeData = Selectors . GetActionsAsTreeViewData ( state , m_GuidToTreeViewId ) ;
146+ var treeData = Selectors . GetActionsAsTreeViewData ( state ) ;
151147 return new ViewState
152148 {
153149 treeViewData = treeData ,
@@ -572,7 +568,7 @@ public ActionOrBindingData(bool isAction, string name, int actionMapIndex, bool
572568
573569 internal static partial class Selectors
574570 {
575- public static List < TreeViewItemData < ActionOrBindingData > > GetActionsAsTreeViewData ( InputActionsEditorState state , Dictionary < Guid , int > idDictionary )
571+ public static List < TreeViewItemData < ActionOrBindingData > > GetActionsAsTreeViewData ( InputActionsEditorState state )
576572 {
577573 var actionMapIndex = state . selectedActionMapIndex ;
578574 var controlSchemes = state . serializedObject . FindProperty ( nameof ( InputActionAsset . m_ControlSchemes ) ) ;
@@ -591,12 +587,13 @@ public static List<TreeViewItemData<ActionOrBindingData>> GetActionsAsTreeViewDa
591587 . ToList ( ) ;
592588
593589 var actionItems = new List < TreeViewItemData < ActionOrBindingData > > ( ) ;
590+ var treeviewItemIDCounter = 0 ;
594591 foreach ( var action in actions )
595592 {
596593 var actionBindings = bindings . Where ( spb => spb . action == action . name ) . ToList ( ) ;
597594 var bindingItems = new List < TreeViewItemData < ActionOrBindingData > > ( ) ;
598595 var actionId = new Guid ( action . id ) ;
599-
596+
600597 for ( var i = 0 ; i < actionBindings . Count ; i ++ )
601598 {
602599 var serializedInputBinding = actionBindings [ i ] ;
@@ -619,7 +616,7 @@ public static List<TreeViewItemData<ActionOrBindingData>> GetActionsAsTreeViewDa
619616 if ( isVisible )
620617 {
621618 var name = GetHumanReadableCompositeName ( nextBinding , state . selectedControlScheme , controlSchemes ) ;
622- compositeItems . Add ( new TreeViewItemData < ActionOrBindingData > ( GetIdForGuid ( new Guid ( nextBinding . id ) , idDictionary ) ,
619+ compositeItems . Add ( new TreeViewItemData < ActionOrBindingData > ( treeviewItemIDCounter ++ ,
623620 new ActionOrBindingData ( isAction : false , name , actionMapIndex , isComposite : false ,
624621 isPartOfComposite : true , GetControlLayout ( nextBinding . path ) , bindingIndex : nextBinding . indexOfBinding , isCut : state . IsBindingCut ( actionMapIndex , nextBinding . indexOfBinding ) ) ) ) ;
625622 }
@@ -637,36 +634,26 @@ public static List<TreeViewItemData<ActionOrBindingData>> GetActionsAsTreeViewDa
637634
638635 var shouldCompositeBeVisible = ! ( compositeItems . Count == 0 && hasHiddenCompositeParts ) ; //hide composite if all parts are hidden
639636 if ( shouldCompositeBeVisible )
640- bindingItems . Add ( new TreeViewItemData < ActionOrBindingData > ( GetIdForGuid ( inputBindingId , idDictionary ) ,
637+ bindingItems . Add ( new TreeViewItemData < ActionOrBindingData > ( treeviewItemIDCounter ++ ,
641638 new ActionOrBindingData ( isAction : false , serializedInputBinding . name , actionMapIndex , isComposite : true , isPartOfComposite : false , action . expectedControlType , bindingIndex : serializedInputBinding . indexOfBinding , isCut : state . IsBindingCut ( actionMapIndex , serializedInputBinding . indexOfBinding ) ) ,
642639 compositeItems . Count > 0 ? compositeItems : null ) ) ;
643640 }
644641 else
645642 {
646643 var isVisible = ShouldBindingBeVisible ( serializedInputBinding , state . selectedControlScheme , state . selectedDeviceRequirementIndex ) ;
647644 if ( isVisible )
648- bindingItems . Add ( new TreeViewItemData < ActionOrBindingData > ( GetIdForGuid ( inputBindingId , idDictionary ) ,
645+ bindingItems . Add ( new TreeViewItemData < ActionOrBindingData > ( treeviewItemIDCounter ++ ,
649646 new ActionOrBindingData ( isAction : false , GetHumanReadableBindingName ( serializedInputBinding , state . selectedControlScheme , controlSchemes ) , actionMapIndex ,
650647 isComposite : false , isPartOfComposite : false , GetControlLayout ( serializedInputBinding . path ) , bindingIndex : serializedInputBinding . indexOfBinding , isCut : state . IsBindingCut ( actionMapIndex , serializedInputBinding . indexOfBinding ) ) ) ) ;
651648 }
652649 }
653650 var actionIndex = action . wrappedProperty . GetIndexOfArrayElement ( ) ;
654- actionItems . Add ( new TreeViewItemData < ActionOrBindingData > ( GetIdForGuid ( actionId , idDictionary ) ,
651+ actionItems . Add ( new TreeViewItemData < ActionOrBindingData > ( treeviewItemIDCounter ++ ,
655652 new ActionOrBindingData ( isAction : true , action . name , actionMapIndex , isComposite : false , isPartOfComposite : false , action . expectedControlType , actionIndex : actionIndex , isCut : state . IsActionCut ( actionMapIndex , actionIndex ) ) , bindingItems . Count > 0 ? bindingItems : null ) ) ;
656653 }
657654 return actionItems ;
658655 }
659656
660- private static int GetIdForGuid ( Guid guid , Dictionary < Guid , int > idDictionary )
661- {
662- if ( ! idDictionary . TryGetValue ( guid , out var id ) )
663- {
664- id = idDictionary . Values . Count > 0 ? idDictionary . Values . Max ( ) + 1 : 0 ;
665- idDictionary . Add ( guid , id ) ;
666- }
667- return id ;
668- }
669-
670657 private static string GetHumanReadableBindingName ( SerializedInputBinding serializedInputBinding , InputControlScheme ? currentControlScheme , SerializedProperty allControlSchemes )
671658 {
672659 var name = InputControlPath . ToHumanReadableString ( serializedInputBinding . path ) ;
0 commit comments