@@ -346,11 +346,7 @@ public InputActionAsset actions
346346
347347 if ( m_Enabled )
348348 {
349- ClearCaches ( ) ;
350- AssignUserAndDevices ( ) ;
351- InitializeActions ( ) ;
352- if ( m_InputActive )
353- ActivateInput ( ) ;
349+ Init ( ) ;
354350 }
355351 }
356352 }
@@ -1363,16 +1359,16 @@ private void InitializeActions()
13631359
13641360 // duplicate action asset to not operate on the original(as it might be used outside - eg project wide action asset or UIInputModule)
13651361 var oldActions = m_Actions ;
1366- m_Actions = Instantiate ( m_Actions ) ;
1362+ var newActions = Instantiate ( m_Actions ) ;
13671363 for ( var actionMap = 0 ; actionMap < oldActions . actionMaps . Count ; actionMap ++ )
13681364 {
13691365 for ( var binding = 0 ; binding < oldActions . actionMaps [ actionMap ] . bindings . Count ; binding ++ )
1370- m_Actions . actionMaps [ actionMap ] . ApplyBindingOverride ( binding , oldActions . actionMaps [ actionMap ] . bindings [ binding ] ) ;
1366+ newActions . actionMaps [ actionMap ] . ApplyBindingOverride ( binding , oldActions . actionMaps [ actionMap ] . bindings [ binding ] ) ;
13711367 }
1372-
1373- // reset state to default, only one action map is enabled at the initial state
1374- // Project wide actions may have enabled action maps
1375- m_Actions . Disable ( ) ;
1368+ //reset state to default, only one action map is enabled at the initial state
1369+ //Project wide actions may have enabled action maps
1370+ newActions . Disable ( ) ;
1371+ m_Actions = newActions ;
13761372
13771373 #if UNITY_INPUT_SYSTEM_ENABLE_UI
13781374 if ( uiInputModule != null )
@@ -1792,15 +1788,10 @@ void Reset()
17921788 private void OnEnable ( )
17931789 {
17941790 m_Enabled = true ;
1795-
17961791 using ( InputActionRebindingExtensions . DeferBindingResolution ( ) )
17971792 {
17981793 AssignPlayerIndex ( ) ;
1799- InitializeActions ( ) ;
1800- AssignUserAndDevices ( ) ;
1801- ActivateInput ( ) ;
18021794 }
1803-
18041795 // Split-screen index defaults to player index.
18051796 if ( s_InitSplitScreenIndex >= 0 )
18061797 m_SplitScreenIndex = splitScreenIndex ;
@@ -1813,6 +1804,9 @@ private void OnEnable()
18131804 for ( var j = i ; j > 0 && s_AllActivePlayers [ j - 1 ] . playerIndex > s_AllActivePlayers [ j ] . playerIndex ; -- j )
18141805 s_AllActivePlayers . SwapElements ( j , j - 1 ) ;
18151806
1807+
1808+ Init ( ) ;
1809+
18161810 // If it's the first player, hook into user change notifications.
18171811 if ( s_AllActivePlayersCount == 1 )
18181812 {
@@ -1844,6 +1838,16 @@ private void OnEnable()
18441838 PlayerInputManager . instance ? . NotifyPlayerJoined ( this ) ;
18451839 }
18461840
1841+ private void Init ( )
1842+ {
1843+ using ( InputActionRebindingExtensions . DeferBindingResolution ( ) )
1844+ {
1845+ InitializeActions ( ) ;
1846+ AssignUserAndDevices ( ) ;
1847+ ActivateInput ( ) ;
1848+ }
1849+ }
1850+
18471851 private void StartListeningForUnpairedDeviceActivity ( )
18481852 {
18491853 if ( m_OnUnpairedDeviceUsedHooked )
0 commit comments