CanvasΒΆ
Inherited: Component
DescriptionΒΆ
Canvas provides an off-screen rendering surface for UI widgets. It renders all child widgets to a texture, which can then be displayed in the scene.
Public MethodsΒΆ
void |
disableClip () |
void |
draw (CommandBuffer * buffer) |
void |
drawMesh (Mesh * mesh, MaterialInstance * material) |
void |
drawRect (MaterialInstance * material, RectTransform * transform) |
void |
markDirty () |
void |
setClipRegion (const Vector4 & region) |
void |
setRectTransform (RectTransform * transform) |
void |
update (const Vector2 & position) |
Static MethodsΒΆ
None
Methods DescriptionΒΆ
void Canvas::disableClip ()
Disables the clip region.
Turns off scissor testing, allowing rendering to the full screen.
void Canvas::draw (CommandBuffer * buffer)
Draws the canvas and its contents uses command buffer to record draw commands into.
void Canvas::drawMesh (Mesh * mesh, MaterialInstance * material)
Draws a mesh with the given material.
void Canvas::drawRect (MaterialInstance * material, RectTransform * transform)
Draws a rectangle with the given material and transform.
Creates a model matrix from the rectβs size and position, combines it with the world transform, and draws the default plane mesh. The hash is computed from the transform and size for batching purposes.
void Canvas::markDirty ()
Marks the canvas as dirty, forcing a re-render.
When marked dirty, the canvas will redraw all child widgets on the next draw call.
RectTransform * Canvas::rectTransform ()
Returns the RectTransform component of the canvas.
Lazy-initializes and caches the RectTransform reference.
See also setRectTransform().
void Canvas::setClipRegion (Vector4 & region)
Sets the clip region (scissor rectangle).
Enables scissor testing to restrict rendering to the specified region. Coordinates are in screen space.
void Canvas::setRectTransform (RectTransform * transform)
Sets the rect transform reference.
Internal method for caching the RectTransform.
See also rectTransform().
void Canvas::update (Vector2 & position)
Updates all child widgets with the given cursor/touch position.
Propagates the update call to all child widgets, setting their canvas reference before updating.