Canvas#

class UI.Canvas()#

A canvas for user interface elements. See UI.getStockCanvas() and UI.addCanvas().

Canvas.getRectTransform()#

The rect transform for the UI object.

Property:

Read-only, cannot be set

Return type:

UI.RectTransform

Canvas.getLayoutElement()#

How much space the UI object asks a layout for.

Property:

Read-only, cannot be set

Return type:

UI.LayoutElement

Note

Only has an effect when the object is in a panel that has a layout. A canvas is not inside a layout and does not have one.

Canvas.getVisible()#
Canvas.setVisible(value)#

Whether the UI object is visible.

Property:

Can be read or written

Return type:

boolean

Note

This is the object’s own setting, which is what it was last set to. An object is only drawn when everything it is inside is visible as well, so an interface can be built with its parts visible, inside a panel that is not, and shown all at once by making that panel visible.

Canvas.addPanel([visible])#

Create a panel within this object.

Arguments:
  • visible (boolean) – Whether the new panel is visible. Defaults to true.

Return type:

UI.Panel

Canvas.addText(content[, visible])#

Add text to this object.

Arguments:
  • content (string) – The text.

  • visible (boolean) – Whether the text is visible. Defaults to true.

Return type:

UI.Text

Canvas.addInputField([visible])#

Add an input field to this object.

Arguments:
  • visible (boolean) – Whether the input field is visible. Defaults to true.

Return type:

UI.InputField

Canvas.addButton(content[, visible])#

Add a button to this object.

Arguments:
  • content (string) – The label for the button.

  • visible (boolean) – Whether the button is visible. Defaults to true.

Return type:

UI.Button

Canvas.addToggle(content[, visible])#

Add a toggle to this object.

Arguments:
  • content (string) – The label for the toggle.

  • visible (boolean) – Whether the toggle is visible. Defaults to true.

Return type:

UI.Toggle

Canvas.addToggleGroup()#

Add a toggle group to this object, to make a set of toggles into radio buttons.

Return type:

UI.ToggleGroup

Note

The group is not drawn and does not take up any space. The toggles that belong to it can be added anywhere.

Canvas.addSlider([vertical[, visible]])#

Add a slider to this object.

Arguments:
  • vertical (boolean) – Whether the slider runs from bottom to top, rather than from left to right. Defaults to false.

  • visible (boolean) – Whether the slider is visible. Defaults to true.

Return type:

UI.Slider

Canvas.addDropdown([visible])#

Add a dropdown to this object.

Arguments:
  • visible (boolean) – Whether the dropdown is visible. Defaults to true.

Return type:

UI.Dropdown

Canvas.addImage([visible])#

Add an image to this object.

Arguments:
  • visible (boolean) – Whether the image is visible. Defaults to true.

Return type:

UI.Image

Canvas.addScrollView([visible])#

Add a scroll view to this object.

Arguments:
  • visible (boolean) – Whether the scroll view is visible. Defaults to true.

Return type:

UI.ScrollView

Canvas.remove()#

Remove the UI object.