Skip to content

Commit 4a697c3

Browse files
Merge branch 'develop' into bugfix/ISXB-1560-inputactionmap-warnings
2 parents 765ee06 + d6f4d02 commit 4a697c3

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

Assets/Tests/InputSystem/Plugins/UITests.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,6 +2764,81 @@ public void UI_ClickDraggingMouseDoesNotAllocateGCMemory()
27642764
}, Is.Not.AllocatingGCMemory());
27652765
}
27662766

2767+
[UnityTest]
2768+
[Category("UI")]
2769+
public IEnumerator UI_CanNavigateUI_WithLocalMultiPlayerRoot_Null_UsingGamepads()
2770+
{
2771+
// Setup navigation
2772+
var gamepad = InputSystem.AddDevice<Gamepad>();
2773+
var scene = CreateTestUI(makeSelectable: true);
2774+
2775+
// Create actions for navigation
2776+
var asset = ScriptableObject.CreateInstance<InputActionAsset>();
2777+
var map = asset.AddActionMap("map");
2778+
var moveAction = map.AddAction("move", type: InputActionType.Value, binding: "<Gamepad>/leftStick");
2779+
var submitAction = map.AddAction("submit", type: InputActionType.Button, binding: "<Gamepad>/buttonSouth");
2780+
2781+
// Assign actions to the UI module
2782+
scene.uiModule.move = InputActionReference.Create(moveAction);
2783+
scene.uiModule.submit = InputActionReference.Create(submitAction);
2784+
map.Enable();
2785+
2786+
// Test 1: Assign localMultiPlayerRoot to a value
2787+
scene.eventSystem.playerRoot = scene.parentGameObject;
2788+
2789+
// Initial selection
2790+
scene.eventSystem.SetSelectedGameObject(scene.leftGameObject);
2791+
yield return null;
2792+
2793+
// Move right
2794+
Set(gamepad.leftStick, new Vector2(1, 0));
2795+
yield return null;
2796+
2797+
Assert.That(scene.eventSystem.currentSelectedGameObject, Is.SameAs(scene.rightGameObject), "Right navigation did not work when localMultiPlayerRoot was set");
2798+
2799+
// Move left
2800+
Set(gamepad.leftStick, Vector2.zero);
2801+
yield return null;
2802+
Set(gamepad.leftStick, new Vector2(-1, 0));
2803+
yield return null;
2804+
2805+
Assert.That(scene.eventSystem.currentSelectedGameObject, Is.SameAs(scene.leftGameObject), "Left navigation did not work when localMultiPlayerRoot was set");
2806+
2807+
// Reset stick position
2808+
Set(gamepad.leftStick, Vector2.zero);
2809+
yield return null;
2810+
2811+
// Test 2: With localMultiPlayerRoot set to null
2812+
scene.eventSystem.playerRoot = null;
2813+
2814+
// Reset selection
2815+
scene.eventSystem.SetSelectedGameObject(scene.leftGameObject);
2816+
yield return null;
2817+
2818+
// Move right
2819+
Set(gamepad.leftStick, new Vector2(1, 0));
2820+
yield return null;
2821+
2822+
Assert.That(scene.eventSystem.currentSelectedGameObject, Is.SameAs(scene.rightGameObject), "Right navigation did not work when localMultiPlayerRoot was null");
2823+
2824+
// Move left
2825+
Set(gamepad.leftStick, Vector2.zero);
2826+
yield return null;
2827+
Set(gamepad.leftStick, new Vector2(-1, 0));
2828+
yield return null;
2829+
2830+
Assert.That(scene.eventSystem.currentSelectedGameObject, Is.SameAs(scene.leftGameObject), "Left navigation did not work when localMultiPlayerRoot was null");
2831+
2832+
// Submit
2833+
PressAndRelease(gamepad.buttonSouth);
2834+
yield return null;
2835+
2836+
Assert.That(scene.leftChildReceiver.events, Has.Exactly(1).With.Property("type").EqualTo(EventType.Submit), "Submit event was not received when localMultiPlayerRoot was null");
2837+
2838+
// Checking that localMultiPlayerRoot is null
2839+
Assert.AreEqual(null, scene.uiModule.localMultiPlayerRoot);
2840+
}
2841+
27672842
[UnityTest]
27682843
[Category("UI")]
27692844
// Check that two players can have separate UI, and that both selections will stay active when

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ however, it has to be formatted properly to pass verification tests.
2424
- Fixed an issue in `RebindingUISample` preventing UI navigation without Keyboard and Mouse present.
2525
- Fixed an issue in `RebindActionUI` which resulted in active binding not being shown after a scene reload. ISXB-1588.
2626
- Fixed an issue in `GamepadIconExample` which resulted in icons for left and right triggers not being displayed after a rebind to the exact same controls. ISXB-1593.
27+
- Fixed an issue where `InputSystemUIInputModule.localMultiPlayerRoot` could not be set to `null` when using `MultiplayerEventSystem`. [ISXB-1610](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1610)
2728

2829
## [1.14.2] - 2025-08-05
2930

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ protected override void OnDisable()
4949

5050
private void InitializePlayerRoot()
5151
{
52-
if (m_PlayerRoot == null) return;
53-
5452
var inputModule = GetComponent<InputSystemUIInputModule>();
5553
if (inputModule != null)
5654
inputModule.localMultiPlayerRoot = m_PlayerRoot;

0 commit comments

Comments
 (0)