@@ -956,7 +956,7 @@ public void ActivateInput()
956956
957957 // reset state to default, only one action map is enabled at the initial state
958958 // Project wide actions may have enabled action maps
959- if ( m_Actions != null )
959+ if ( m_Actions )
960960 m_Actions . Disable ( ) ;
961961
962962 // If we have no current action map but there's a default
@@ -1373,18 +1373,14 @@ private void InitializeActions()
13731373 if ( m_Actions == null )
13741374 return ;
13751375
1376- // don't use project wide action asset for player input, but duplicate it
1377- if ( InputSystem . actions != null && InputSystem . actions . Equals ( m_Actions ) )
1378- DuplicateActionsForPlayer ( ) ;
1379-
1380- // Check if we need to duplicate our actions by looking at all other players. If any
1381- // has the same actions, duplicate.
1382- for ( var i = 0 ; i < s_AllActivePlayersCount ; ++ i )
1383- if ( s_AllActivePlayers [ i ] . m_Actions == m_Actions && s_AllActivePlayers [ i ] != this )
1384- {
1385- DuplicateActionsForPlayer ( ) ;
1386- break ;
1387- }
1376+ // duplicate action asset to not operate on the original (as it might be used outside - eg project wide action asset or UIInputModule)
1377+ var oldActions = m_Actions ;
1378+ m_Actions = Instantiate ( m_Actions ) ;
1379+ for ( var actionMap = 0 ; actionMap < oldActions . actionMaps . Count ; actionMap ++ )
1380+ {
1381+ for ( var binding = 0 ; binding < oldActions . actionMaps [ actionMap ] . bindings . Count ; binding ++ )
1382+ m_Actions . actionMaps [ actionMap ] . ApplyBindingOverride ( binding , oldActions . actionMaps [ actionMap ] . bindings [ binding ] ) ;
1383+ }
13881384
13891385 #if UNITY_INPUT_SYSTEM_ENABLE_UI
13901386 if ( uiInputModule != null )
@@ -1432,17 +1428,6 @@ private void InitializeActions()
14321428 m_ActionsInitialized = true ;
14331429 }
14341430
1435- private void DuplicateActionsForPlayer ( )
1436- {
1437- var oldActions = m_Actions ;
1438- m_Actions = Instantiate ( m_Actions ) ;
1439- for ( var actionMap = 0 ; actionMap < oldActions . actionMaps . Count ; actionMap ++ )
1440- {
1441- for ( var binding = 0 ; binding < oldActions . actionMaps [ actionMap ] . bindings . Count ; binding ++ )
1442- m_Actions . actionMaps [ actionMap ] . ApplyBindingOverride ( binding , oldActions . actionMaps [ actionMap ] . bindings [ binding ] ) ;
1443- }
1444- }
1445-
14461431 private void UninitializeActions ( )
14471432 {
14481433 if ( ! m_ActionsInitialized )
0 commit comments