Table of Contents

Class Button

Namespace
MagicUI.Elements
Assembly
MagicUI.dll

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 LayoutRoot

The layout root to draw the button on

name string

The name of the button

Properties

BorderColor

The border color of the button

public Color BorderColor { get; set; }

Property Value

Color

Borderless

Whether the button should be displayed in a borderless style.

public bool Borderless { get; set; }

Property Value

bool

Content

The button's content

public string Content { get; set; }

Property Value

string

ContentColor

The color of the text in the button

public Color ContentColor { get; set; }

Property Value

Color

Enabled

Whether the button is enabled

public bool Enabled { get; set; }

Property Value

bool

Font

The font to use to display the content

public Font Font { get; set; }

Property Value

Font

FontSize

The font size of the content

public int FontSize { get; set; }

Property Value

int

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

float

MinHeight

The minimum height of the button

public float MinHeight { get; set; }

Property Value

float

MinWidth

The minimum width of the button

public float MinWidth { get; set; }

Property Value

float

Methods

ArrangeOverride(Vector2)

Internal implementation to position the object within the allocated space.

protected override void ArrangeOverride(Vector2 alignedTopLeftCorner)

Parameters

alignedTopLeftCorner Vector2

The 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

Vector2

Events

Click

Event that fires when the button is clicked

public event Action<Button>? Click

Event Type

Action<Button>

OnHover

Event that fires when the button is hovered over, either by mouse or controller inputs.

public event Action<Button>? OnHover

Event Type

Action<Button>

OnUnhover

Event that fires when the button stops being hovered over, either by mouse or controller inputs.

public event Action<Button>? OnUnhover

Event Type

Action<Button>