IN THIS ARTICLE
Placing UI Canvases in the 3D World
You can place a UI canvas directly on an object in the 3D world, as opposed to showing it in screen space. To do this, you render a UI canvas to a texture, and then use that texture in a material of a mesh or actor.
You can use any material on an entity to display a texture rendered by a UI canvas. To interact with a canvas on a mesh or actor, the entity requires a UI Canvas on Mesh component.
In the canvas properties, enable the Render to texture property.
In the Render Target property, click the button and select an
.attimageAttachment Image asset. Refer to Attachment Image assets for an example
In the level, create an entity.
With the entity selected, in the Entity Inspector, add a UI Canvas Asset Ref component to the entity and select the UI canvas you created. Enable Load automatically.
Add a Mesh component to the entity and select a Model Asset.
Add a Material component to the entity and select a material to display the canvas on. Edit the material instance by clicking on the arrow next to the Model Materials property. Select Open Material Instance Editor…. In the Material Instance Editor, update the Base Color texture to the same Attachment Image asset as the UI canvas’ Render Target.
(For interactable canvases) Add a UI Canvas on Mesh component to the entity. If you want to load multiple instances of the UI canvas on different entities and have them display different states, select the Attachment Image asset in the Render target override property. Otherwise, leave this property blank.Note:You must create a unique Attachment Image asset for each entity, assign that asset the entity’s material, and then assign the Attachment Image asset in the Render target override property.
The following image shows an entity that is configured to display a non-interactable canvas on its mesh.