Search Issue Tracker

By Design

By Design in 6000.5.X

Votes

0

Found in

6000.0.70f1

6000.3.10f1

6000.4.0b11

6000.5.0a8

Issue ID

UUM-136660

Regression

No

Panel.Pick() returns incorrect elements when the target UIDocument's Render Mode is set to World Space

UI Toolkit Framework

-

How to reproduce:
1. Open the attached “IN-134930“ project
2. Open the “Scene“ scene
3. Enter Play mode
4. In the Game view, click on the Yellow stripe
5. Observe the Console

Actual result: Panel.Pick() returned null
Expected result: Panel.Pick() returned “Yellow”

Reproducible with: 2023.2.0a7 (954df492642e), 6000.0.70f1, 6000.3.10f1, 6000.4.0b11, 6000.5.0a8

Reproducible on: Windows 11
Not reproducible on: No other environments tested

Note: GameObject holding the UIDocument Component has to be rotated to not face the active Camera for the issue to reproduce

  1. Resolution Note:

    Panel.Pick was never intended to work with world space content. We can't fix the Panel.Pick method to accept flat coordinates in the original document's inverse-transformed space because of the way the documents set their transform matrix on their rootVisualElement, which effectively requires a 3-D world coordinate as the entry point. A single panel can host multiple documents with various 3-D transforms on them, which makes the notion of a 2-D "panel coordinate" generally invalid in world space.

    We do plan on releasing new, better-adapted methods for world-space interactions, notably for picking, but these will come as a feature release and not a bug fix.

    That being said, I found a workaround by playing around that will make Pick work in the provided repro project:
    - Create a new GameObject with an empty UIDocument using the same PanelSettings
    - Place the new document's transform at (0,0,0) with default rotation and scale.
    - Put the original document as a child to the new one (creating a nested UIDocument).
    - Make sure to choose Position=Absolute in the nested document's inspector.
    - Enter play mode and click on the color bands. Observe the console.

  2. Resolution Note (6000.5.X):

    Panel.Pick was never intended to work with world space content. We can't fix the Panel.Pick method to accept flat coordinates in the original document's inverse-transformed space because of the way the documents set their transform matrix on their rootVisualElement, which effectively requires a 3-D world coordinate as the entry point. A single panel can host multiple documents with various 3-D transforms on them, which makes the notion of a 2-D "panel coordinate" generally invalid in world space.

    We do plan on releasing new, better-adapted methods for world-space interactions, notably for picking, but these will come as a feature release and not a bug fix.

    That being said, I found a workaround by playing around that will make Pick work in the provided repro project:
    - Create a new GameObject with an empty UIDocument using the same PanelSettings
    - Place the new document's transform at (0,0,0) with default rotation and scale.
    - Put the original document as a child to the new one (creating a nested UIDocument).
    - Make sure to choose Position=Absolute in the nested document's inspector.
    - Enter play mode and click on the color bands. Observe the console.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.