Skip to content

Conversation

andrew-oc
Copy link
Contributor

Fogbugz
Issue Tracker

Description

IPointerEnterHandler and IPointerExitHandler interfaces did not work when the cursor was locked. This made it impossible to use PhysicsRaycaster to interact with world space UI or objects using pointer-driven gaze direction. The issue occurs because when the cursor is locked, the raycast origin is placed outside the screen, which causes raycast logic to short-circuit and always miss all objects.

Changes made

Added the CursorLockBehaviour enum and a setting in InputSystemUIInputModule to allow the user to specify that when the cursor is locked, raycasts should originate from the center of the screen.

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.
    • FogBugz ticket attached, example ([case %number%](https://issuetracker.unity3d.com/issues/...)).
    • FogBugz is marked as "Resolved" with next release version correctly set.
  • 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.

EditorGUIUtility.TrTextContent("Cursor Lock Behavior",
$"Controls the origin point of UI raycasts when the cursor is locked. {InputSystemUIInputModule.CursorLockBehavior.OutsideScreen} " +
$"is the default behavior and will force the raycast to miss all objects. {InputSystemUIInputModule.CursorLockBehavior.ScreenCenter} " +
$"will cast the ray from the center of the screen."));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably update manual screenshot and doc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree, and include @duckets on the review after the change

EditorGUIUtility.TrTextContent("Cursor Lock Behavior",
$"Controls the origin point of UI raycasts when the cursor is locked. {InputSystemUIInputModule.CursorLockBehavior.OutsideScreen} " +
$"is the default behavior and will force the raycast to miss all objects. {InputSystemUIInputModule.CursorLockBehavior.ScreenCenter} " +
$"will cast the ray from the center of the screen."));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree, and include @duckets on the review after the change

* Updated documentation and images
* Fixed compile error on newer versions of Unity due to UIElements
@andrew-oc andrew-oc merged commit 352b6c5 into develop Mar 31, 2022
@andrew-oc andrew-oc deleted the fix-1395281 branch March 31, 2022 06:56
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.

3 participants