Function: createUiCanvas()
createUiCanvas(
world,renderContext,options):number
Defined in: ui/utilities/create-ui-canvas.ts:132
Creates a UI canvas: a root entity with a CanvasEcsComponent and
RectTransformEcsComponent. For renderMode: 'screenSpace' (the
default), also a dedicated, static UI camera with a transparent clear
color, its own off-screen RenderTarget, and a culling mask isolating it
from the world so a world camera whose own cullingMask still matches
everything doesn't draw UI content a second time. For
renderMode: 'worldSpace', no camera is created - options.camera names
the (typically world) camera this canvas draws through instead.
Call registerUiSystems(world, renderContext, time) once per world
before (or after - registration order between the two doesn't matter,
only tick order does) creating any canvases; this function only creates
the canvas entity itself; it never touches system registration, so it's
always safe to call once per canvas, however many canvases a world has.
Parameters
world
The ECS world to create the canvas entity in.
renderContext
The render context a 'screenSpace' canvas's UI
camera/render target is built against. Unused for 'worldSpace'.
options
Options for configuring the canvas and its focus
navigation inputs. Which fields are available - cullingMask/
referenceResolution/scaleMode/layer vs. camera/anchor/
anchoredPosition - depends on renderMode, enforced at compile time
(see ScreenSpaceUiCanvasOptions/WorldSpaceUiCanvasOptions).
Returns
number
The created canvas entity. Attach children to it with
addParentComponent(world, child, { parent: canvas }), or use
createPanel/createLabel/createButton.