Class Button
A button element
public sealed class Button : ArrangableElement, IGameObjectWrapper, IControllerInteractable
- Inheritance
-
Button
- Implements
- Inherited Members
- Extension Methods
Constructors
Button(LayoutRoot, string)
Creates a button
public Button(LayoutRoot onLayout, string name = "New Button")
Parameters
onLayout
LayoutRootThe layout root to draw the button on
name
stringThe name of the button
Properties
BorderColor
The border color of the button
public Color BorderColor { get; set; }
Property Value
Borderless
Whether the button should be displayed in a borderless style.
public bool Borderless { get; set; }
Property Value
Content
The button's content
public string Content { get; set; }
Property Value
ContentColor
The color of the text in the button
public Color ContentColor { get; set; }
Property Value
Enabled
Whether the button is enabled
public bool Enabled { get; set; }
Property Value
Font
The font to use to display the content
public Font Font { get; set; }
Property Value
FontSize
The font size of the content
public int FontSize { get; set; }
Property Value
GameObject
The UnityEngine.GameObject underlying this UI element
public GameObject GameObject { get; }
Property Value
- GameObject
Margin
The internal margin between the button's content and its border
public float Margin { get; set; }
Property Value
MinHeight
The minimum height of the button
public float MinHeight { get; set; }
Property Value
MinWidth
The minimum width of the button
public float MinWidth { get; set; }
Property Value
Methods
ArrangeOverride(Vector2)
Internal implementation to position the object within the allocated space.
protected override void ArrangeOverride(Vector2 alignedTopLeftCorner)
Parameters
alignedTopLeftCorner
Vector2The space available for the element.
DestroyOverride()
Internal implementation to perform any additional cleanup when the element is destroyed
protected override void DestroyOverride()
GetSelectable()
Gets the Unity UnityEngine.UI.Selectable underlying the element
public Selectable GetSelectable()
Returns
- Selectable
MeasureOverride()
Internal implementation to calculate desired size.
protected override Vector2 MeasureOverride()
Returns
Events
Click
Event that fires when the button is clicked
public event Action<Button>? Click
Event Type
OnHover
Event that fires when the button is hovered over, either by mouse or controller inputs.
public event Action<Button>? OnHover
Event Type
OnUnhover
Event that fires when the button stops being hovered over, either by mouse or controller inputs.
public event Action<Button>? OnUnhover