Skip to content
Open
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
34 changes: 34 additions & 0 deletions Assets/Tests/InputSystem/Plugins/OnScreenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,40 @@ public IEnumerator Devices_OnScreenStickDoesNotReceivePointerUpEventsInIsolatedM
Assert.That(stick.gameObject.GetComponent<RectTransform>().anchoredPosition, Is.Not.EqualTo(stickOriginPosition));
}

[UnityTest]
[Category("Devices")]
public IEnumerator OnScreenStick_IsolateMode_ShouldCastRayToChild()
{
InputSystem.AddDevice<Touchscreen>();

var uiTestScene = new UITestScene(this);

var stickRect = uiTestScene.AddImage("StickParent");
var stick = stickRect.gameObject.AddComponent<OnScreenStick>();
stick.controlPath = "<Gamepad>/leftStick";
stick.useIsolatedInputActions = true;

var childGO = new GameObject("StickImage", typeof(RectTransform), typeof(Image));
var childRect = childGO.GetComponent<RectTransform>();
childRect.SetParent(stickRect, worldPositionStays: false);
childRect.anchorMin = Vector2.zero;
childRect.anchorMax = Vector2.one;
childRect.sizeDelta = Vector2.zero;
childGO.GetComponent<Image>().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")]
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 @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down