diff --git a/Assets/Tests/InputSystem/Plugins/OnScreenTests.cs b/Assets/Tests/InputSystem/Plugins/OnScreenTests.cs index c25675a958..43a53315f3 100644 --- a/Assets/Tests/InputSystem/Plugins/OnScreenTests.cs +++ b/Assets/Tests/InputSystem/Plugins/OnScreenTests.cs @@ -582,6 +582,40 @@ public IEnumerator Devices_OnScreenStickDoesNotReceivePointerUpEventsInIsolatedM Assert.That(stick.gameObject.GetComponent().anchoredPosition, Is.Not.EqualTo(stickOriginPosition)); } + [UnityTest] + [Category("Devices")] + public IEnumerator OnScreenStick_IsolateMode_ShouldCastRayToChild() + { + InputSystem.AddDevice(); + + var uiTestScene = new UITestScene(this); + + var stickRect = uiTestScene.AddImage("StickParent"); + var stick = stickRect.gameObject.AddComponent(); + stick.controlPath = "/leftStick"; + stick.useIsolatedInputActions = true; + + var childGO = new GameObject("StickImage", typeof(RectTransform), typeof(Image)); + var childRect = childGO.GetComponent(); + childRect.SetParent(stickRect, worldPositionStays: false); + childRect.anchorMin = Vector2.zero; + childRect.anchorMax = Vector2.one; + childRect.sizeDelta = Vector2.zero; + childGO.GetComponent().raycastTarget = true; + + var stickOriginPosition = stickRect.anchoredPosition; + + // Ensure that the OnScreenStick component has been started. + yield return null; + + yield return uiTestScene.PressAndDrag(childRect, new Vector2(50, 0)); + + // Allow one more frame for queued events to be processed. + yield return null; + + Assert.That(stickRect.anchoredPosition, Is.Not.EqualTo(stickOriginPosition)); + } + // https://fogbugz.unity3d.com/f/cases/1305016/ [Test] [Category("Devices")] diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index fb7dbba1bb..28fe13d605 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -21,6 +21,7 @@ however, it has to be formatted properly to pass verification tests. - Align title font size with toolbar style in `Input Action` window. - Updated Action Properties headers to use colors consistent with GameObject component headers. - Fixed misaligned Virtual Cursor when changing resolution [ISXB-1119](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1119) +- Fixed OnScreenStick ignoring dynamic-origin presses when isolated input actions were enabled. [ISXB-1027](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1027) ### Added diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs index 25920c27c2..7767c76b5c 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs @@ -252,7 +252,7 @@ private void OnPointerDown(InputAction.CallbackContext ctx) var stickSelected = false; foreach (var result in m_RaycastResults) { - if (result.gameObject != gameObject) continue; + if (!result.gameObject.transform.IsChildOf(transform)) continue; stickSelected = true; break;