From c562118cf434a058dc91f6084b5fb95405b4001e Mon Sep 17 00:00:00 2001 From: Aswin Gopal Date: Tue, 17 Feb 2026 16:52:19 +0530 Subject: [PATCH 1/4] Added test to cover the fix. --- .../InputSystem/Plugins/InputForUITests.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Assets/Tests/InputSystem/Plugins/InputForUITests.cs b/Assets/Tests/InputSystem/Plugins/InputForUITests.cs index c279d7a157..878dbee010 100644 --- a/Assets/Tests/InputSystem/Plugins/InputForUITests.cs +++ b/Assets/Tests/InputSystem/Plugins/InputForUITests.cs @@ -92,6 +92,33 @@ public void InputSystemActionAssetIsNotNull() "Test is invalid since InputSystemProvider actions are not available"); } + [Test] + [Category(kTestCategory)] + public void Shutdown_DoesNotDisableProjectWideActionsAsset() + { + var asset = ScriptableObject.CreateInstance(); + var uiMap = new InputActionMap("UI"); + uiMap.AddAction("Point", InputActionType.PassThrough, "/position"); + uiMap.AddAction("Navigate", InputActionType.PassThrough, "/leftStick"); + uiMap.AddAction("Submit", InputActionType.Button, "/enter"); + uiMap.AddAction("Cancel", InputActionType.Button, "/escape"); + uiMap.AddAction("Click", InputActionType.PassThrough, "/leftButton"); + uiMap.AddAction("MiddleClick", InputActionType.PassThrough, "/middleButton"); + uiMap.AddAction("RightClick", InputActionType.PassThrough, "/rightButton"); + uiMap.AddAction("ScrollWheel", InputActionType.PassThrough, "/scroll"); + asset.AddActionMap(uiMap); + + InputSystem.s_Manager.actions = asset; + + m_InputSystemProvider.Initialize(); + Assert.That(asset.enabled, Is.True, "Project-wide actions should be enabled by provider initialization."); + + m_InputSystemProvider.Shutdown(); + Assert.That(asset.enabled, Is.True, "Project-wide actions must remain enabled after provider shutdown."); + + Object.DestroyImmediate(asset); + } + [Test] [Category(kTestCategory)] // Checks that mouse events are ignored when a touch is active. From 0ed73d817a657209950405eb9d6eb3396b3a4d33 Mon Sep 17 00:00:00 2001 From: Aswin Gopal Date: Tue, 17 Feb 2026 16:52:37 +0530 Subject: [PATCH 2/4] Fix: Avoid disabling project-wide actions on shutdown --- .../InputSystem/Plugins/InputForUI/InputSystemProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs index 1b056f7e76..cfdfd07c98 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs @@ -664,7 +664,7 @@ void UnregisterActions() UnregisterAction(ref m_RightClickAction, OnRightClickPerformed); UnregisterAction(ref m_ScrollWheelAction, OnScrollWheelPerformed); - if (m_InputActionAsset != null) + if (m_InputActionAsset != null && m_InputActionAsset != InputSystem.actions) m_InputActionAsset.Disable(); } From 61807cc684c40eb3eaa5bcae778dc0a0c27a140f Mon Sep 17 00:00:00 2001 From: Aswin Gopal Date: Tue, 3 Mar 2026 16:10:36 +0530 Subject: [PATCH 3/4] Fix test double shutdown call causing issues. --- Assets/Tests/InputSystem/Plugins/InputForUITests.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/Tests/InputSystem/Plugins/InputForUITests.cs b/Assets/Tests/InputSystem/Plugins/InputForUITests.cs index 878dbee010..0075067a63 100644 --- a/Assets/Tests/InputSystem/Plugins/InputForUITests.cs +++ b/Assets/Tests/InputSystem/Plugins/InputForUITests.cs @@ -37,6 +37,7 @@ public class InputForUITests : InputTestFixture readonly List m_InputForUIEvents = new List(); private int m_CurrentInputEventToCheck; InputSystemProvider m_InputSystemProvider; + private bool m_ClearedMockProvider; private InputActionAsset storedActions; @@ -45,6 +46,7 @@ public override void Setup() { base.Setup(); m_CurrentInputEventToCheck = 0; + m_ClearedMockProvider = false; storedActions = InputSystem.actions; @@ -59,7 +61,8 @@ public override void Setup() public override void TearDown() { EventProvider.Unsubscribe(InputForUIOnEvent); - EventProvider.ClearMockProvider(); + if (!m_ClearedMockProvider) + EventProvider.ClearMockProvider(); m_InputForUIEvents.Clear(); InputSystem.s_Manager.actions = storedActions; @@ -113,7 +116,8 @@ public void Shutdown_DoesNotDisableProjectWideActionsAsset() m_InputSystemProvider.Initialize(); Assert.That(asset.enabled, Is.True, "Project-wide actions should be enabled by provider initialization."); - m_InputSystemProvider.Shutdown(); + EventProvider.ClearMockProvider(); + m_ClearedMockProvider = true; Assert.That(asset.enabled, Is.True, "Project-wide actions must remain enabled after provider shutdown."); Object.DestroyImmediate(asset); From b087ccd1e8bb7aaebc4f0f15269ce0719f9f3d81 Mon Sep 17 00:00:00 2001 From: Aswin Gopal Date: Mon, 23 Mar 2026 15:20:12 +0530 Subject: [PATCH 4/4] Fix InputForUI action lifecycle to only manage the UI action map. --- .../Plugins/InputForUI/InputSystemProvider.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs index cfdfd07c98..272994b1d5 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs @@ -17,6 +17,8 @@ internal class InputSystemProvider : IEventProviderImpl DefaultInputActions m_DefaultInputActions; InputActionAsset m_InputActionAsset; + InputActionMap m_UIActionMap; + bool m_ShouldDisableUIActionMapOnUnregister; // Note that these are plain action references instead since InputActionReference do // not provide any value when this integration doesn't have any UI. If this integration @@ -636,14 +638,11 @@ void RegisterActions() m_RightClickAction = FindActionAndRegisterCallback(Actions.RightClickAction, OnRightClickPerformed); m_ScrollWheelAction = FindActionAndRegisterCallback(Actions.ScrollWheelAction, OnScrollWheelPerformed); - // When adding new actions, don't forget to add them to UnregisterActions - if (InputSystem.actions == null) - { - // If we've not loaded a user-created set of actions, just enable the UI actions from our defaults. - m_InputActionAsset.FindActionMap("UI", true).Enable(); - } - else - m_InputActionAsset.Enable(); + // Only touch the UI map so we don't change the enabled state of unrelated maps. + m_UIActionMap = m_InputActionAsset?.FindActionMap("UI", true); + m_ShouldDisableUIActionMapOnUnregister = m_UIActionMap != null && !m_UIActionMap.enabled; + if (m_ShouldDisableUIActionMapOnUnregister) + m_UIActionMap.Enable(); } void UnregisterAction(ref InputAction action, Action callback = null) @@ -664,8 +663,11 @@ void UnregisterActions() UnregisterAction(ref m_RightClickAction, OnRightClickPerformed); UnregisterAction(ref m_ScrollWheelAction, OnScrollWheelPerformed); - if (m_InputActionAsset != null && m_InputActionAsset != InputSystem.actions) - m_InputActionAsset.Disable(); + if (m_ShouldDisableUIActionMapOnUnregister && m_UIActionMap != null) + m_UIActionMap.Disable(); + + m_UIActionMap = null; + m_ShouldDisableUIActionMapOnUnregister = false; } void SelectInputActionAsset()