Skip to content

FIX: disabling the InputSystemUIInputModule component resets all actions to None #2192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void Report(string message)
}
}

[Test(Description = "Verifies that the default asset do not generate any verification errors (Regardless of existing requirements)")]
[Test(Description = "Verifies that the default asset does not generate any verification errors (Regardless of existing requirements)")]
[Category(kTestCategory)]
public void ProjectWideActions_ShouldSupportAssetVerification_AndHaveNoVerificationErrorsForDefaultAsset()
{
Expand Down
11 changes: 11 additions & 0 deletions Assets/Tests/InputSystem/Plugins/UITests.InputModuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ public IEnumerator PointerExitChildShouldFullyExit()
Assert.IsTrue(callbackCheck.pointerData.fullyExited == true);
}

[UnityTest]
[Description("Regression test for https://jira.unity3d.com/browse/ISXB-1493")]
public IEnumerator DisablingDoesNotResetActions()
{
m_InputModule.enabled = false;

yield return null;

Assert.IsNotNull(m_InputModule.cancel, "Disabling component shouldn't lose its data.");
}

public class PointerExitCallbackCheck : MonoBehaviour, IPointerExitHandler
{
public PointerEventData pointerData { get; private set; }
Expand Down
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed Gamepad stick up/down inputs that were not recognized in WebGL. [ISXB-1090](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1090)
- Fixed reenabling the VirtualMouseInput component may sometimes lead to NullReferenceException. [ISXB-1096](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1096)
- Fixed the default button press point not being respected in Editor (as well as some other Touchscreen properties). [ISXB-1152](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1152)
- Fixed actions being reset when disabling the InputSystemUIInputModule component [ISXB-1493](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1493)
- Fixed PlayerInput component automatically switching away from the default ActionMap set to 'None'.
- Fixed a console error being shown when targeting visionOS builds in 2022.3.
- Fixed a Tap Interaction issue with analog controls. The Tap interaction would keep re-starting after timeout. [ISXB-627](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-627)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,17 @@
set => SwapAction(ref m_TrackedDevicePositionAction, value, m_ActionsHooked, m_OnTrackedDevicePositionDelegate);
}

// We should dispose the static default actions thing because otherwise it will survive domain reloads
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void ResetDefaultActions()
{
if (defaultActions != null)
{
defaultActions.Dispose();
defaultActions = null;
}
}

Check warning on line 1540 in Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs#L1534-L1540

Added lines #L1534 - L1540 were not covered by tests

/// <summary>
/// Assigns default input actions asset and input actions, similar to how defaults are assigned when creating UI module in editor.
/// Useful for creating <see cref="InputSystemUIInputModule"/> at runtime.
Expand Down Expand Up @@ -1665,7 +1676,6 @@
InputActionState.s_GlobalState.onActionControlsChanged.RemoveCallback(m_OnControlsChangedDelegate);
DisableAllActions();
UnhookActions();
UnassignActions();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ This line is very wrong, it results in user data being lost on component deactivation.


base.OnDisable();
}
Expand Down