Panel#

class UI.Panel#

A container for user interface elements. Added to a UI.Canvas or another panel.

rect_transform: UI.RectTransform#

The rect transform for the UI object.

Attribute:

Read-only, cannot be set

Return type:

UI.RectTransform

layout_element: UI.LayoutElement#

How much space the UI object asks a layout for.

Attribute:

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.

style: UI.PanelStyle#

How the background of the panel is drawn. A box is the frame to group related controls in, and is how a group box is made.

Attribute:

Can be read or written

Return type:

UI.PanelStyle

color: StdLib.ColorRGBA#

The color the background of the panel is tinted with.

Attribute:

Can be read or written

Return type:

StdLib.ColorRGBA

Note

Has no effect while the style of the panel is UI.PanelStyle.none, as the panel is then not drawn at all.

draggable: boolean#

Whether the user can move the panel by dragging it.

Attribute:

Can be read or written

Return type:

boolean

Note

Dragging anywhere on the panel moves it, including over the elements it contains, unless one of them takes the pointer for itself. Give a panel a title bar of its own if only part of it should move it. A panel whose style is UI.PanelStyle.none is not drawn, so it takes no pointer events of its own and can only be dragged by the elements it contains.

visible: boolean#

Whether the UI object is visible.

Attribute:

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.

add_panel([visible = true])#

Create a panel within this object.

Parameters:

visible (boolean) – Whether the new panel is visible.

Return type:

UI.Panel

add_text(content[, visible = true])#

Add text to this object.

Parameters:
  • content (string) – The text.

  • visible (boolean) – Whether the text is visible.

Return type:

UI.Text

add_input_field([visible = true])#

Add an input field to this object.

Parameters:

visible (boolean) – Whether the input field is visible.

Return type:

UI.InputField

add_button(content[, visible = true])#

Add a button to this object.

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

  • visible (boolean) – Whether the button is visible.

Return type:

UI.Button

add_toggle(content[, visible = true])#

Add a toggle to this object.

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

  • visible (boolean) – Whether the toggle is visible.

Return type:

UI.Toggle

add_toggle_group()#

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.

add_slider([vertical = false][, visible = true])#

Add a slider to this object.

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

  • visible (boolean) – Whether the slider is visible.

Return type:

UI.Slider

add_dropdown([visible = true])#

Add a dropdown to this object.

Parameters:

visible (boolean) – Whether the dropdown is visible.

Return type:

UI.Dropdown

add_image([visible = true])#

Add an image to this object.

Parameters:

visible (boolean) – Whether the image is visible.

Return type:

UI.Image

add_scroll_view([visible = true])#

Add a scroll view to this object.

Parameters:

visible (boolean) – Whether the scroll view is visible.

Return type:

UI.ScrollView

layout: UI.Layout#

The layout that arranges the elements of the panel, or nil if they are positioned by hand.

Attribute:

Read-only, cannot be set

Return type:

UI.Layout or Types.none

add_horizontal_layout()#

Arrange the elements of the panel in a row.

Return type:

UI.Layout

add_vertical_layout()#

Arrange the elements of the panel in a column.

Return type:

UI.Layout

add_grid_layout()#

Arrange the elements of the panel in a grid of equally sized cells.

Return type:

UI.Layout

Note

The number of columns follows from the size of the panel and the size of a cell. Use UI.Layout.constraint to fix it instead.

size_fitter: UI.SizeFitter#

Sizes the panel to fit what it contains.

Attribute:

Read-only, cannot be set

Return type:

UI.SizeFitter

Note

Both directions start out unconstrained, which leaves the size of the panel alone.

bring_to_front()#

Draw the panel in front of the other elements beside it. Elements are drawn in the order they were added, so of two overlapping panels the newer hides part of the older until the older is brought to the front.

Note

A draggable panel also brings itself to the front when the user starts dragging it, the way a window comes to the front when it is clicked.

remove()#

Remove the UI object.

class UI.PanelStyle#

How the background of a panel is drawn.

window#

As a window, the heavier of the two frames the game uses.

box#

As a box, the lighter frame the game groups related controls in.

none#

Not drawn at all, leaving whatever is behind the panel showing through.