UIDocument on a separate Camera+ViewRect

Is it possible to have the UIToolkit’s UIDocument in a Scene be rendered (and handle events) on a non-overlapping part of the screen? Typically this is done with two cameras with non-overlapping viewrects.

I saw some posts with using RenderTarget, but that implicates complicated event handling on the UI elements (say button press, dropdown). Am I correct here, in that we’d have to manually do raycast and handle the events and do much more work than vanilla UIDocument.

Any other ways to approach non-overlapping game area and UI area with UIDocument?

UI toolkit is rendered as an overlay directly on the screen if no render texture is specified in the panelSettings, independently of any camera in the scene. If you want to have two independent UI on your screen at different place, You can simply have two UIDocuments using (or not) the same panelSettings. The main reason to have two different panelSettings is to handle the scaling of the ui differently.

Is there something more specific you want to achieve?

Yes. At runtime I want 70% of the screen [x: 0.0-0.7, y:0.0-1.0] to contain the Game and the rest 30% [x:0.7-1.0, y: 0.0-1.0] to contain a UIDocument.
Prefer to not do manual raycasting to handle UI events.

Just put all your UI in a visual element with Left=70%, Right=0%, Top = 0%, Bottom = 0%, and you should be good. If you want to be certain that if a child element will not be display if it is outside, you can set overflow=hidden.

Thanks! This solved the rendering issue.

1 Like