Skip to content

Commit 9ca2549

Browse files
committed
reset the default actions static field during scene load to fix it having junk after reloading
1 parent 1b49fef commit 9ca2549

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,17 @@ public InputActionReference trackedDevicePosition
15281528
set => SwapAction(ref m_TrackedDevicePositionAction, value, m_ActionsHooked, m_OnTrackedDevicePositionDelegate);
15291529
}
15301530

1531+
// We should dispose the static default actions thing because otherwise it will survive domain reloads
1532+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
1533+
static void ResetDefaultActions()
1534+
{
1535+
if (defaultActions != null)
1536+
{
1537+
defaultActions.Dispose();
1538+
defaultActions = null;
1539+
}
1540+
}
1541+
15311542
/// <summary>
15321543
/// Assigns default input actions asset and input actions, similar to how defaults are assigned when creating UI module in editor.
15331544
/// Useful for creating <see cref="InputSystemUIInputModule"/> at runtime.
@@ -1665,7 +1676,6 @@ protected override void OnDisable()
16651676
InputActionState.s_GlobalState.onActionControlsChanged.RemoveCallback(m_OnControlsChangedDelegate);
16661677
DisableAllActions();
16671678
UnhookActions();
1668-
UnassignActions();
16691679

16701680
base.OnDisable();
16711681
}

0 commit comments

Comments
 (0)