Skip to content

Commit 6afc84a

Browse files
committed
changed to duplicate actions for playerinput instead of using project wide action asset directly
1 parent d9e3b6a commit 6afc84a

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

Packages/com.unity.inputsystem/InputSystem/InputSystem.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,8 +3035,7 @@ private static void EnableActions()
30353035
if (actions == null)
30363036
return;
30373037

3038-
if (!actions.enabled)
3039-
actions.Enable();
3038+
actions.Enable();
30403039
}
30413040

30423041
private static void DisableActions(bool triggerSetupChanged = false)

Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInput.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,19 +1373,16 @@ 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+
13761380
// Check if we need to duplicate our actions by looking at all other players. If any
13771381
// has the same actions, duplicate.
13781382
for (var i = 0; i < s_AllActivePlayersCount; ++i)
13791383
if (s_AllActivePlayers[i].m_Actions == m_Actions && s_AllActivePlayers[i] != this)
13801384
{
1381-
var oldActions = m_Actions;
1382-
m_Actions = Instantiate(m_Actions);
1383-
for (var actionMap = 0; actionMap < oldActions.actionMaps.Count; actionMap++)
1384-
{
1385-
for (var binding = 0; binding < oldActions.actionMaps[actionMap].bindings.Count; binding++)
1386-
m_Actions.actionMaps[actionMap].ApplyBindingOverride(binding, oldActions.actionMaps[actionMap].bindings[binding]);
1387-
}
1388-
1385+
DuplicateActionsForPlayer();
13891386
break;
13901387
}
13911388

@@ -1435,6 +1432,17 @@ private void InitializeActions()
14351432
m_ActionsInitialized = true;
14361433
}
14371434

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+
14381446
private void UninitializeActions()
14391447
{
14401448
if (!m_ActionsInitialized)

0 commit comments

Comments
 (0)