uiLayoutRect
此内容尚不支持你的语言。
uiLayoutRect(
cam,fit,width,height,previewAspect?):WorldRect
Defined in: camera/uiLayoutRect.ts:103
The world-space box the UI subtree is laid out within (UINode px are world
units in this box), for the primary camera. Its SIZE is the area UI lays out in;
its CENTER is where that area sits in the world, which places screen roots (a UI
root with no transform parent) — so in play the HUD tracks the camera.
Scene cameras already bake the fit’s design resolution into halfW/halfH, so their box is simply those extents centered on the camera — UINode px map 1:1 to design px and the UI is stable. The editor view instead renders the world at a free zoom with a raw orthoSize (editorCameraInfo passes a null fit, for predictable navigation), so laying UI out in its zoomed extents would rescale and reflow every element on each zoom. For it, recover the fixed design-resolution box from the fit and anchor it at EDITOR_UI_ANCHOR: the UI then lays out identically at any zoom or pan, and still scales visually with the scene because it renders through the same zoomed viewProjection.
With no fit (no Canvas and no project fit) the editor falls back to its own extents — there is nothing to lay out, so it doesn’t matter.
Parameters
Section titled “Parameters”CanvasScale | null
number
height
Section titled “height”number
previewAspect?
Section titled “previewAspect?”number = 0