Panel#
- class Panel#
A container for user interface elements. Added to a
Canvasor another panel.- RectTransform RectTransform { get; }#
The rect transform for the UI object.
- Game Scenes:
All
- LayoutElement LayoutElement { get; }#
How much space the UI object asks a layout for.
- Game Scenes:
All
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.
- PanelStyle Style { get; set; }#
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.
- Game Scenes:
All
- StdLib.ColorRGBA Color { get; set; }#
The color the background of the panel is tinted with.
- Game Scenes:
All
Note
Has no effect while the style of the panel is
PanelStyle.None, as the panel is then not drawn at all.
- bool Draggable { get; set; }#
Whether the user can move the panel by dragging it.
- Game Scenes:
All
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
PanelStyle.Noneis not drawn, so it takes no pointer events of its own and can only be dragged by the elements it contains.
- bool Visible { get; set; }#
Whether the UI object is visible.
- Game Scenes:
All
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.
- Panel AddPanel (bool visible = true)#
Create a panel within this object.
- Parameters:
visible – Whether the new panel is visible.
- Game Scenes:
All
- Text AddText (string content, bool visible = true)#
Add text to this object.
- Parameters:
content – The text.
visible – Whether the text is visible.
- Game Scenes:
All
- InputField AddInputField (bool visible = true)#
Add an input field to this object.
- Parameters:
visible – Whether the input field is visible.
- Game Scenes:
All
- Button AddButton (string content, bool visible = true)#
Add a button to this object.
- Parameters:
content – The label for the button.
visible – Whether the button is visible.
- Game Scenes:
All
- Toggle AddToggle (string content, bool visible = true)#
Add a toggle to this object.
- Parameters:
content – The label for the toggle.
visible – Whether the toggle is visible.
- Game Scenes:
All
- ToggleGroup AddToggleGroup ()#
Add a toggle group to this object, to make a set of toggles into radio buttons.
- Game Scenes:
All
Note
The group is not drawn and does not take up any space. The toggles that belong to it can be added anywhere.
- Slider AddSlider (bool vertical = false, bool visible = true)#
Add a slider to this object.
- Parameters:
vertical – Whether the slider runs from bottom to top, rather than from left to right.
visible – Whether the slider is visible.
- Game Scenes:
All
- Dropdown AddDropdown (bool visible = true)#
Add a dropdown to this object.
- Parameters:
visible – Whether the dropdown is visible.
- Game Scenes:
All
- Image AddImage (bool visible = true)#
Add an image to this object.
- Parameters:
visible – Whether the image is visible.
- Game Scenes:
All
- ScrollView AddScrollView (bool visible = true)#
Add a scroll view to this object.
- Parameters:
visible – Whether the scroll view is visible.
- Game Scenes:
All
- Layout Layout { get; }#
The layout that arranges the elements of the panel, or
nullif they are positioned by hand.- Game Scenes:
All
- Layout AddGridLayout ()#
Arrange the elements of the panel in a grid of equally sized cells.
- Game Scenes:
All
Note
The number of columns follows from the size of the panel and the size of a cell. Use
Layout.Constraintto fix it instead.
- SizeFitter SizeFitter { get; }#
Sizes the panel to fit what it contains.
- Game Scenes:
All
Note
Both directions start out unconstrained, which leaves the size of the panel alone.
- void BringToFront ()#
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.
- Game Scenes:
All
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.
- void Remove ()#
Remove the UI object.
- Game Scenes:
All