UI Render Scene
Updated
The small 3D world a UI Render View shows.
- Type
ent-ui-render-scene- Script class
UIRenderSceneEntity- Family
- UI
Overview
Section titled “Overview”A UI Render Scene is the small 3D world a UI Render View shows. It sits directly under a UI Render View and holds the models to display. Its UI Render Scene component (comp-ui-render-scene) gives that world its own camera and lights: the camera sits on the render scene’s +Z axis at distance metres, looking at its origin, and a key light, a fill light and an ambient light light it.
The render scene is not a UI element itself; it is a 3D container that is drawn only in its view. The main camera, shadows and reflections never see it, and the world’s lights never reach it. You still select and edit its entities in the editor like any others.
It accepts primitives, 3D models (glTF, FBX, OBJ, USDZ, Collada, kit pieces) and Behaviors, nested at any depth. Adding any other kind of entity, such as a light or a camera, throws.
The props that matter most:
distance: how far the camera is from the origin, in metres (3 by default). Smaller is closer.fov: the camera’s vertical field of view in degrees (30 by default). A narrow field flattens perspective, like a telephoto lens.background:'transparent'(the default), letting the panel show through, or a colour behind the models.
Set it up
Section titled “Set it up”- Add a UI Render Scene directly under a UI Render View. See Scenes and hierarchy.
- Put the models under it, centred on its origin, where the camera looks.
- Set
distanceso the model fills the view, and abackgroundif the panel behind should not show through.
Examples
Section titled “Examples”Zoom with a slider
Section titled “Zoom with a slider”Goal: a slider moves the camera closer to or further from the previewed model.
#pragma lifecycle(startup)
// Scene: a UI Render Scene named 'Preview Scene' under a UI Render View,// and a UI Slider named 'Zoom' with a Signal Emitter on 'preview:zoom'.function startup() { const world = findEntity('Preview Scene').getComponent(UIRenderSceneComponent); const zoom = findEntity('Zoom').getComponent(UISliderComponent);
zoom.setProps({ text: 'Zoom', min: 1, max: 6, step: 0.1, unit: 'm', showValue: true });
on('preview:zoom', (event) => { if (event.eventType === EventType.UISlider.Change) world.setProps({ distance: event.data.value }); });
zoom.setValue(world.props.distance ?? 3);}How it works:
- The slider’s value is the camera distance in metres, from 1 to 6.
- Each step sets
distance; the camera moves along +Z, still looking at the origin. - The slider starts at the render scene’s current distance.
A background per item
Section titled “A background per item”Goal: give each previewed item its own backdrop colour and framing.
#pragma lifecycle(startup)
// Scene: a UI Render Scene named 'Preview Scene'. Other scripts emit 'shop:preview'// with { rarity } when a new item is shown: 'common', 'rare' or 'legendary'.const LOOKS = { common: { background: '#1e293b', fov: 30, distance: 3 }, rare: { background: '#1e3a8a', fov: 30, distance: 2.6 }, legendary: { background: '#78350f', fov: 22, distance: 3.4 },};
function startup() { const world = findEntity('Preview Scene').getComponent(UIRenderSceneComponent);
on('shop:preview', (data) => { world.setProps(LOOKS[data.rarity] ?? LOOKS.common); });}How it works:
- One
setPropscall changes the background colour, the field of view and the distance together. - A narrower
fovwith a largerdistanceframes the model at a similar size with flatter perspective, for a more dramatic look.
Components
Section titled “Components”What a new UI Render Scene is made of. Required components are always present and cannot be removed; the others can. Per entity says whether an entity can hold one of that component or several. Layer, Lock and Enable are on every placed entity, and Transform holds its position, rotation and scale.
| Component | Type | Role | Per entity | What it does |
|---|---|---|---|---|
| Layer | comp-layer |
Required | One | Puts the entity on a render/raycast layer so cameras and rays can include or skip it. |
| Lock | comp-lock |
Required | One | Editor-only flag that stops the entity from being selected or moved. |
| Enable | comp-enable |
Required | One | Turns the entity and its children on or off: hides them and stops their behavior. |
| Transform | comp- |
Required | One | Position, rotation and scale of the entity, with optional editor-only per-axis locks. |
| UI Render Scene | comp- |
Required | One | The small 3D world a UI Render View shows. |
You can also add 1 optional components, such as Signal Emitter.
The settings of a new entity, as the runtime creates it. Change them in the Properties panel of XR Creator, or from a script with getComponent(…).setProps({ … }).
| Prop | Default | Range |
|---|---|---|
fov |
30 |
1 ≤ x ≤ 179 |
distance |
3 |
0. |
background |
"transparent" |
Events
Section titled “Events”With a Signal Emitter on the entity, these events reach scripts as { entityId, eventType, data }. Compare eventType with the EventType constants.
It reports the events every entity has: Transform::change (and position-change, rotation-change, scale-change), Enable::change, Layer::change and Lock::change.
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
A character preview inside a panel: a UI Render View shows a UI Render Scene with its own camera and lights, and a Behavior turns the model in it.
Watch Amelia turn inside the panel: she lives in the render scene, lit by its own lights. Drag outside the panel to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”Find the entity by its name, check its class, and work with its components. Name the entity in the Hierarchy first; this example expects My UI Render Scene.
#pragma lifecycle(startup)
function startup() { // Find the entity by the name it has in the Hierarchy. const entity = findEntity('My UI Render Scene'); if (!(entity instanceof UIRenderSceneEntity)) return;
// Its UI Render Scene component holds the settings listed under Props. const component = entity.getComponent(UIRenderSceneComponent); log('fov is', component.props.fov); component.setProps({ fov: 45 });}