1
1
#if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
2
2
using System ;
3
3
using System . Collections . Generic ;
4
- using System . Collections . ObjectModel ;
5
4
using System . Linq ;
6
5
using UnityEditor ;
7
6
@@ -92,7 +91,6 @@ public InputActionsEditorState(
92
91
int selectedActionIndex = 0 ,
93
92
int selectedBindingIndex = 0 ,
94
93
SelectionType selectionType = SelectionType . Action ,
95
- Dictionary < ( string , string ) , HashSet < int > > expandedBindingIndices = null ,
96
94
InputControlScheme selectedControlScheme = default ,
97
95
int selectedControlSchemeIndex = - 1 ,
98
96
int selectedDeviceRequirementIndex = - 1 ,
@@ -112,9 +110,6 @@ public InputActionsEditorState(
112
110
m_selectedControlSchemeIndex = selectedControlSchemeIndex ;
113
111
m_selectedDeviceRequirementIndex = selectedDeviceRequirementIndex ;
114
112
115
- m_ExpandedCompositeBindings = expandedBindingIndices == null ?
116
- new Dictionary < ( string , string ) , HashSet < int > > ( ) :
117
- new Dictionary < ( string , string ) , HashSet < int > > ( expandedBindingIndices ) ;
118
113
m_CutElements = cutElements ;
119
114
}
120
115
@@ -201,12 +196,6 @@ public InputActionsEditorState(InputActionsEditorState other, SerializedObject a
201
196
m_ControlScheme = new InputControlScheme ( ) ;
202
197
}
203
198
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
-
210
199
m_CutElements = other . cutElements ;
211
200
}
212
201
@@ -218,7 +207,6 @@ public InputActionsEditorState With(
218
207
InputControlScheme ? selectedControlScheme = null ,
219
208
int ? selectedControlSchemeIndex = null ,
220
209
int ? selectedDeviceRequirementIndex = null ,
221
- Dictionary < ( string , string ) , HashSet < int > > expandedBindingIndices = null ,
222
210
List < CutElement > cutElements = null )
223
211
{
224
212
return new InputActionsEditorState (
@@ -228,7 +216,6 @@ public InputActionsEditorState With(
228
216
selectedActionIndex ?? this . selectedActionIndex ,
229
217
selectedBindingIndex ?? this . selectedBindingIndex ,
230
218
selectionType ?? this . selectionType ,
231
- expandedBindingIndices ?? m_ExpandedCompositeBindings ,
232
219
233
220
// Control schemes
234
221
selectedControlScheme ?? this . selectedControlScheme ,
@@ -248,7 +235,6 @@ public InputActionsEditorState ClearCutElements()
248
235
selectedActionIndex ,
249
236
selectedBindingIndex ,
250
237
selectionType ,
251
- m_ExpandedCompositeBindings ,
252
238
selectedControlScheme ,
253
239
selectedControlSchemeIndex ,
254
240
selectedDeviceRequirementIndex ,
@@ -262,39 +248,6 @@ public SerializedProperty GetActionMapByName(string actionMapName)
262
248
. FirstOrDefault ( p => p . FindPropertyRelative ( nameof ( InputActionMap . m_Name ) ) . stringValue == actionMapName ) ;
263
249
}
264
250
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
-
298
251
public InputActionsEditorState SelectAction ( string actionName )
299
252
{
300
253
var actionMap = GetSelectedActionMap ( ) ;
@@ -419,48 +372,11 @@ public readonly List<CutElement> GetCutElements()
419
372
return m_CutElements ;
420
373
}
421
374
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
-
454
375
private SerializedProperty GetSelectedActionMap ( )
455
376
{
456
377
return Selectors . GetActionMapAtIndex ( serializedObject , selectedActionMapIndex ) ? . wrappedProperty ;
457
378
}
458
379
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 ;
463
-
464
380
private readonly InputControlScheme m_ControlScheme ;
465
381
}
466
382
0 commit comments