Canvas#

class UI.Canvas#

A canvas for user interface elements. See UI.stock_canvas and UI.add_canvas().

rect_transform: UI.RectTransform#

The rect transform for the UI object.

Attribute:

Read-only, cannot be set

layout_element: UI.LayoutElement#

How much space the UI object asks a layout for.

Attribute:

Read-only, cannot be set

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.

visible: boolean#

Whether the UI object is visible.

Attribute:

Can be read or written

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.

add_panel(visible?: boolean): UI.Panel#

Create a panel within this object.

Parameters:

visible – Whether the new panel is visible. Defaults to true.

add_text(content: string, visible?: boolean): UI.Text#

Add text to this object.

Parameters:
  • content – The text.

  • visible – Whether the text is visible. Defaults to true.

add_input_field(visible?: boolean): UI.InputField#

Add an input field to this object.

Parameters:

visible – Whether the input field is visible. Defaults to true.

add_button(content: string, visible?: boolean): UI.Button#

Add a button to this object.

Parameters:
  • content – The label for the button.

  • visible – Whether the button is visible. Defaults to true.

add_toggle(content: string, visible?: boolean): UI.Toggle#

Add a toggle to this object.

Parameters:
  • content – The label for the toggle.

  • visible – Whether the toggle is visible. Defaults to true.

add_toggle_group(): UI.ToggleGroup#

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

Note

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

add_slider(vertical?: boolean, visible?: boolean): UI.Slider#

Add a slider to this object.

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

  • visible – Whether the slider is visible. Defaults to true.

add_dropdown(visible?: boolean): UI.Dropdown#

Add a dropdown to this object.

Parameters:

visible – Whether the dropdown is visible. Defaults to true.

add_image(visible?: boolean): UI.Image#

Add an image to this object.

Parameters:

visible – Whether the image is visible. Defaults to true.

add_scroll_view(visible?: boolean): UI.ScrollView#

Add a scroll view to this object.

Parameters:

visible – Whether the scroll view is visible. Defaults to true.

remove()#

Remove the UI object.