UI Render View
Updated
Shows a small 3D scene inside the UI.
- Type
ent-ui-render-view- Script class
UIRenderViewEntity- Family
- UI
Overview
Section titled “Overview”A UI Render View shows a small, live 3D world inside a UI: a model turning in a shop panel, a character preview in a lobby, an item in an inventory slot. Its UI Render View component (comp-ui-render-view) is the picture: a box sized like an image that displays what a camera sees. The world it shows is a UI Render Scene entity placed under it, which holds the models and has its own camera and lights.
UI Panel└── UI Render View the picture: size and quality └── UI Render Scene the world: camera, lights, background ├── Preview Model (a 3D model) └── Behavior turns the modelA render view sits nested in a panel or layout. Everything in its render scene is drawn only in the view: the main camera, shadows and reflections never see it, and the world’s lights never reach it. While on screen, the view draws its small world once per frame; a hidden or off-screen view draws nothing.
Use a UI Render View when the player should see a real 3D object inside a UI. For a still picture, a UI Image costs far less.
The props that matter most:
widthandheight: the box in layout pixels (px), 256 × 256 by default.quality: the picture’s resolution on its long side,'low'(256 pixels),'medium'(512, the default) or'high'(1024).borderRadius: rounded corners in px.
Set it up
Section titled “Set it up”- Add a UI Render View under a UI Panel or UI Layout. See Scenes and hierarchy.
- Add a UI Render Scene directly under it.
- Put the models to show under the render scene: primitives, 3D models and Behaviors only.
- Set the view’s
width,heightandquality, and the render scene’sdistanceandbackground.
Examples
Section titled “Examples”A turntable
Section titled “A turntable”Goal: turn the previewed model slowly and continuously.
#pragma lifecycle(startup, update)
// Scene: a UI Render View whose UI Render Scene holds a model named 'Preview Model'.const SPEED = 0.6; // radians a secondlet model;
function startup() { model = findEntity('Preview Model');}
function update(dt) { model.rotation.y += dt * SPEED;}How it works:
update(dt)turns the model by its share of a full turn every frame.- Turn the model, not the render scene: the render scene’s camera is fixed to it, looking at its origin.
Browse several models
Section titled “Browse several models”Goal: Previous and Next buttons switch which model the view shows.
#pragma lifecycle(startup)
// Scene: a UI Render View whose UI Render Scene named 'Showcase' holds three models// named 'Helmet', 'Shield' and 'Sword', a UI Label named 'Item Name', and UI Buttons// with Signal Emitters on 'showcase:prev' and 'showcase:next'.const ITEMS = ['Helmet', 'Shield', 'Sword'];let index = 0;
function startup() { const label = findEntity('Item Name').getComponent(UILabelComponent);
function show() { ITEMS.forEach((name, i) => findEntity(name).setEnabled(i === index)); label.setProps({ text: ITEMS[index] }); }
on('showcase:prev', (event) => { if (event.eventType !== EventType.UIButton.Press) return; index = (index + ITEMS.length - 1) % ITEMS.length; show(); }); on('showcase:next', (event) => { if (event.eventType !== EventType.UIButton.Press) return; index = (index + 1) % ITEMS.length; show(); });
show();}How it works:
- All three models live in the render scene;
setEnabledshows only the current one. - The label below the view names the item, and the buttons wrap around at both ends.
A larger, sharper view on demand
Section titled “A larger, sharper view on demand”Goal: a toggle button enlarges the preview and raises its quality while inspecting.
#pragma lifecycle(startup)
// Scene: a UI Render View named 'Preview' and a UI Toggle Button named 'Inspect'// with a Signal Emitter on 'preview:inspect'.function startup() { const view = findEntity('Preview').getComponent(UIRenderViewComponent); view.setProps({ width: 200, height: 200, quality: 'low', borderRadius: 12 });
on('preview:inspect', (event) => { if (event.eventType !== EventType.UIToggleButton.Change) return; if (event.data.checked) view.setProps({ width: 400, height: 400, quality: 'high' }); else view.setProps({ width: 200, height: 200, quality: 'low' }); });}How it works:
- A small thumbnail needs little resolution, so
quality: 'low'keeps it cheap. - While inspecting, the view doubles in size and switches to
'high'so detail stays sharp.
Components
Section titled “Components”What a new UI Render View 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 View | comp- |
Required | One | Shows a small 3D scene inside the UI. |
You can also add 2 optional components, such as Signal Emitter, UI Tooltip.
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 |
|---|---|---|
quality |
"medium" |
|
width |
256 |
0. |
height |
256 |
0. |
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 View.
#pragma lifecycle(startup)
function startup() { // Find the entity by the name it has in the Hierarchy. const entity = findEntity('My UI Render View'); if (!(entity instanceof UIRenderViewEntity)) return;
// Its UI Render View component holds the settings listed under Props. const component = entity.getComponent(UIRenderViewComponent); log('width is', component.props.width); component.setProps({ width: 384 });}