Skip to content

UIViewport

Class ยท server and client scripts

UIViewport draws the world as a camera sees it inside a UI element's box. Spawn an entity with Box and UIViewport components to render a camera view inside UI.

Example

-- Client script: show the world from a second camera.
local cam = World.Spawn({ CameraLens = {}, Position = Vector3.new(0, 20, 30) })
cam.Parent = World
local view = World.Spawn({ Box = {}, UIViewport = { CurrentCamera = cam } })
view.Parent = World.Viewport.Screen

CurrentCamera

Property
CurrentCamera: Entity?

CurrentCamera is the camera whose image fills the element. The camera's CameraTarget sets the image size, 512 by 512 without one, and whether the sky or a transparent background is behind the world. nil draws nothing.

Default nil

ViewportColor

Property
ViewportColor: Color

ViewportColor multiplies the view's RGB channels; white keeps its colors unchanged.

Default Color.new(1, 1, 1, 1)

ViewportAlpha

Property
ViewportAlpha: number

ViewportAlpha multiplies the view's opacity from 0 to 1.

Default 1