Skip to content

FIX: OnScreenStick isolated dynamic origin hit detection.#2341

Open
AswinRajGopal wants to merge 3 commits intodevelopfrom
fix/isxb-1027/isolated-inputaction
Open

FIX: OnScreenStick isolated dynamic origin hit detection.#2341
AswinRajGopal wants to merge 3 commits intodevelopfrom
fix/isxb-1027/isolated-inputaction

Conversation

@AswinRajGopal
Copy link
Collaborator

Description

Bug: https://issuetracker.unity3d.com/issues/inputsystems-onscreenstick-behaves-differently-when-using-exactpositionwithdynamicorigin-and-isolated-input-actions-enabled-slash-disabled

With isolated input actions enabled, OnScreenStick only accepted raycast hits on the stick’s root object. In dynamic origin mode the raycast actually hits the child DynamicOriginClickable graphic which leads to the stick to ignore the press and never re-center.

Fix is to treat raycast hits on any child of the stick as valid in isolated mode.

Testing status & QA

Manually verified with the repro steps provided in the case.

Overall Product Risks

  • Complexity: Low
  • Halo Effect: Low

Comments to reviewers

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

@u-pr
Copy link
Contributor

u-pr bot commented Feb 5, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪

The PR consists of a very small change (one line of logic) using standard Unity API, making it very easy to verify against the problem description.
🏅 Score: 95

The fix correctly addresses the hierarchy issue by using `IsChildOf` to allow interaction with child elements (like the dynamic origin graphic), which aligns with the PR description.
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected
  • Update review

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr

@u-pr
Copy link
Contributor

u-pr bot commented Feb 5, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent stick activation through blocking UI

Iterating through all raycast results causes the stick to be selectable even when
obscured by other blocking UI elements (like popups or buttons). To respect UI
occlusion and prevent "click-through" behavior, you should only validate the
top-most raycast result.

Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs [252-259]

-var stickSelected = false;
-foreach (var result in m_RaycastResults)
-{
-    if (!result.gameObject.transform.IsChildOf(transform)) continue;
+// Check only the top-most element to respect UI occlusion
+        var stickSelected = m_RaycastResults[0].gameObject.transform.IsChildOf(transform);
 
-    stickSelected = true;
-    break;
-}
-
Suggestion importance[1-10]: 8

__

Why: Iterating through all raycast results ignores UI occlusion, allowing the control to be activated through other blocking UI elements (like popups). Verifying only the top-most result ensures that the control respects occlusion, preventing unwanted click-through behavior.

Medium
  • More suggestions

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr

@codecov-github-com
Copy link

codecov-github-com bot commented Feb 5, 2026

Codecov Report

All modified and coverable lines are covered by tests ✅

@@           Coverage Diff            @@
##           develop    #2341   +/-   ##
========================================
  Coverage    77.95%   77.95%           
========================================
  Files          476      476           
  Lines        97453    97499   +46     
========================================
+ Hits         75971    76008   +37     
- Misses       21482    21491    +9     
Flag Coverage Δ
inputsystem_MacOS_2022.3 5.54% <ø> (+<0.01%) ⬆️
inputsystem_MacOS_2022.3_project 75.48% <100.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.0 5.32% <ø> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 77.37% <100.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.3 5.32% <ø> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 77.37% <100.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.4 5.32% <ø> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 77.38% <100.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.5 5.32% <ø> (-0.01%) ⬇️
inputsystem_MacOS_6000.5_project 77.38% <100.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_2022.3 5.54% <ø> (+<0.01%) ⬆️
inputsystem_Ubuntu_2022.3_project 75.28% <100.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.0 5.32% <ø> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.17% <100.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.3 5.32% <ø> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.17% <100.00%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.4 5.33% <ø> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.18% <100.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.5 5.33% <ø> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.18% <100.00%> (+0.01%) ⬆️
inputsystem_Windows_2022.3 5.54% <ø> (+<0.01%) ⬆️
inputsystem_Windows_2022.3_project 75.61% <100.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.0 5.32% <ø> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 77.50% <100.00%> (+<0.01%) ⬆️
inputsystem_Windows_6000.3 5.32% <ø> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 77.50% <100.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.4 5.32% <ø> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 77.50% <100.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.5 5.32% <ø> (-0.01%) ⬇️
inputsystem_Windows_6000.5_project 77.50% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Assets/Tests/InputSystem/Plugins/OnScreenTests.cs 99.04% <100.00%> (+0.04%) ⬆️
...stem/InputSystem/Plugins/OnScreen/OnScreenStick.cs 73.23% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Pauliusd01
Copy link
Collaborator

/test_plan

@u-pr
Copy link
Contributor

u-pr bot commented Feb 18, 2026

Test Plan

  • Test plan approved by PR author
  • Test execution in progress
  • Test execution complete
  • Ready for merge

Summary of Changes & Risk Assessment

Summary of Changes

This PR fixes a bug in OnScreenStick where interactions were ignored when useIsolatedInputActions was enabled and the raycast hit a child object (common in dynamic origin mode). The logic in OnPointerDown was updated to check if the hit object is a child of the stick rather than checking for an exact match with the stick's root GameObject.

Risk Assessment

  • High Risk Areas: None identified.
  • Medium Risk Areas: UI Interaction/Occlusion (ensuring children don't "steal" input meant for other elements).
  • Low Risk Areas: Isolated input action logic, standard OnScreenStick behavior.

Test Scenarios

Functional Testing

  • Child Hit Detection: Verify that OnScreenStick with useIsolatedInputActions = true correctly activates when clicking on a child graphic (e.g., DynamicOriginClickable).
  • Root Hit Detection: Verify that clicking directly on the root GameObject of the stick still triggers the interaction correctly.
  • Isolated Mode Validation: Run the new test case OnScreenStick_IsolateMode_ShouldCastRayToChild in OnScreenTests.cs:L587.

Regression Testing

  • Standard Mode: Verify that OnScreenStick functionality is unaffected when useIsolatedInputActions is set to false.
  • External Hits: Verify that clicking on a UI element that is not a child of the OnScreenStick (e.g., a sibling button) does not trigger the stick.
  • Hierarchy Change: Verify behavior when children are added or removed from the stick hierarchy at runtime while isolated mode is active.
🔍 Regression Deep Dive (additional risks identified)
  • UI Occlusion Check: Verify behavior when the OnScreenStick child is obscured by another UI element (like a popup). Ensure the stick does not "click-through" if the top-most raycast result belongs to a different UI hierarchy.
  • Deep Nesting: Test hit detection when the clickable graphic is multiple levels deep in the hierarchy (e.g., Stick -> Container -> Graphic).

Edge Cases

  • Overlapping Sticks: Test two OnScreenStick components where one's child rect overlaps the other's child rect. Verify only the intended stick is activated.
  • Disabled Raycast Targets: Verify that child objects with raycastTarget = false do not trigger the stick activation in OnScreenStick.cs:L255.

💡 This test plan updates automatically when /test_plan is run on new commits. If you have any feedback, please reach out in #ai-qa


🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants