11#if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
22using System ;
33using System . Collections . Generic ;
4- using System . Collections . ObjectModel ;
54using System . Linq ;
65using UnityEditor ;
76
@@ -92,7 +91,6 @@ public InputActionsEditorState(
9291 int selectedActionIndex = 0 ,
9392 int selectedBindingIndex = 0 ,
9493 SelectionType selectionType = SelectionType . Action ,
95- Dictionary < ( string , string ) , HashSet < int > > expandedBindingIndices = null ,
9694 InputControlScheme selectedControlScheme = default ,
9795 int selectedControlSchemeIndex = - 1 ,
9896 int selectedDeviceRequirementIndex = - 1 ,
@@ -112,9 +110,6 @@ public InputActionsEditorState(
112110 m_selectedControlSchemeIndex = selectedControlSchemeIndex ;
113111 m_selectedDeviceRequirementIndex = selectedDeviceRequirementIndex ;
114112
115- m_ExpandedCompositeBindings = expandedBindingIndices == null ?
116- new Dictionary < ( string , string ) , HashSet < int > > ( ) :
117- new Dictionary < ( string , string ) , HashSet < int > > ( expandedBindingIndices ) ;
118113 m_CutElements = cutElements ;
119114 }
120115
@@ -201,12 +196,6 @@ public InputActionsEditorState(InputActionsEditorState other, SerializedObject a
201196 m_ControlScheme = new InputControlScheme ( ) ;
202197 }
203198
204- // Editor may leave these as null after domain reloads, so recreate them in that case.
205- // If they exist, we attempt to just preserve the same expanded items based on name for now for simplicity.
206- m_ExpandedCompositeBindings = other . m_ExpandedCompositeBindings == null ?
207- new Dictionary < ( string , string ) , HashSet < int > > ( ) :
208- new Dictionary < ( string , string ) , HashSet < int > > ( other . m_ExpandedCompositeBindings ) ;
209-
210199 m_CutElements = other . cutElements ;
211200 }
212201
@@ -218,7 +207,6 @@ public InputActionsEditorState With(
218207 InputControlScheme ? selectedControlScheme = null ,
219208 int ? selectedControlSchemeIndex = null ,
220209 int ? selectedDeviceRequirementIndex = null ,
221- Dictionary < ( string , string ) , HashSet < int > > expandedBindingIndices = null ,
222210 List < CutElement > cutElements = null )
223211 {
224212 return new InputActionsEditorState (
@@ -228,7 +216,6 @@ public InputActionsEditorState With(
228216 selectedActionIndex ?? this . selectedActionIndex ,
229217 selectedBindingIndex ?? this . selectedBindingIndex ,
230218 selectionType ?? this . selectionType ,
231- expandedBindingIndices ?? m_ExpandedCompositeBindings ,
232219
233220 // Control schemes
234221 selectedControlScheme ?? this . selectedControlScheme ,
@@ -248,7 +235,6 @@ public InputActionsEditorState ClearCutElements()
248235 selectedActionIndex ,
249236 selectedBindingIndex ,
250237 selectionType ,
251- m_ExpandedCompositeBindings ,
252238 selectedControlScheme ,
253239 selectedControlSchemeIndex ,
254240 selectedDeviceRequirementIndex ,
@@ -262,39 +248,6 @@ public SerializedProperty GetActionMapByName(string actionMapName)
262248 . FirstOrDefault ( p => p . FindPropertyRelative ( nameof ( InputActionMap . m_Name ) ) . stringValue == actionMapName ) ;
263249 }
264250
265- public InputActionsEditorState ExpandCompositeBinding ( SerializedInputBinding binding )
266- {
267- var key = GetSelectedActionMapAndActionKey ( ) ;
268-
269- var expandedCompositeBindings = new Dictionary < ( string , string ) , HashSet < int > > ( m_ExpandedCompositeBindings ) ;
270- if ( ! expandedCompositeBindings . TryGetValue ( key , out var expandedStates ) )
271- {
272- expandedStates = new HashSet < int > ( ) ;
273- expandedCompositeBindings . Add ( key , expandedStates ) ;
274- }
275-
276- expandedStates . Add ( binding . indexOfBinding ) ;
277-
278- return With ( expandedBindingIndices : expandedCompositeBindings ) ;
279- }
280-
281- public InputActionsEditorState CollapseCompositeBinding ( SerializedInputBinding binding )
282- {
283- var key = GetSelectedActionMapAndActionKey ( ) ;
284-
285- if ( m_ExpandedCompositeBindings . ContainsKey ( key ) == false )
286- throw new InvalidOperationException ( "Trying to collapse a composite binding tree that was never expanded." ) ;
287-
288- // do the dance of C# immutability
289- var oldExpandedCompositeBindings = m_ExpandedCompositeBindings ;
290- var expandedCompositeBindings = oldExpandedCompositeBindings . Keys . Where ( dictKey => dictKey != key )
291- . ToDictionary ( dictKey => dictKey , dictKey => oldExpandedCompositeBindings [ dictKey ] ) ;
292- var newHashset = new HashSet < int > ( m_ExpandedCompositeBindings [ key ] . Where ( index => index != binding . indexOfBinding ) ) ;
293- expandedCompositeBindings . Add ( key , newHashset ) ;
294-
295- return With ( expandedBindingIndices : expandedCompositeBindings ) ;
296- }
297-
298251 public InputActionsEditorState SelectAction ( string actionName )
299252 {
300253 var actionMap = GetSelectedActionMap ( ) ;
@@ -419,47 +372,11 @@ public readonly List<CutElement> GetCutElements()
419372 return m_CutElements ;
420373 }
421374
422- public ReadOnlyCollection < int > GetOrCreateExpandedState ( )
423- {
424- return new ReadOnlyCollection < int > ( GetOrCreateExpandedStateInternal ( ) . ToList ( ) ) ;
425- }
426-
427- private HashSet < int > GetOrCreateExpandedStateInternal ( )
428- {
429- var key = GetSelectedActionMapAndActionKey ( ) ;
430-
431- if ( m_ExpandedCompositeBindings . TryGetValue ( key , out var expandedStates ) )
432- return expandedStates ;
433-
434- expandedStates = new HashSet < int > ( ) ;
435- m_ExpandedCompositeBindings . Add ( key , expandedStates ) ;
436- return expandedStates ;
437- }
438-
439- internal ( string , string ) GetSelectedActionMapAndActionKey ( )
440- {
441- var selectedActionMap = GetSelectedActionMap ( ) ;
442-
443- var selectedAction = selectedActionMap
444- . FindPropertyRelative ( nameof ( InputActionMap . m_Actions ) )
445- . GetArrayElementAtIndex ( selectedActionIndex ) ;
446-
447- var key = (
448- selectedActionMap . FindPropertyRelative ( nameof ( InputActionMap . m_Name ) ) . stringValue ,
449- selectedAction . FindPropertyRelative ( nameof ( InputAction . m_Name ) ) . stringValue
450- ) ;
451- return key ;
452- }
453-
454375 private SerializedProperty GetSelectedActionMap ( )
455376 {
456377 return Selectors . GetActionMapAtIndex ( serializedObject , selectedActionMapIndex ) ? . wrappedProperty ;
457378 }
458-
459- /// <summary>
460- /// Expanded states for the actions tree view. These are stored per InputActionMap
461- /// </summary>
462- private readonly Dictionary < ( string , string ) , HashSet < int > > m_ExpandedCompositeBindings ;
379+
463380
464381 private readonly InputControlScheme m_ControlScheme ;
465382 }
0 commit comments