ButtonComponent
extends LabelComponent implements IStylable<ButtonComponent, ButtonStyle>, ICopyable<ButtonComponent>, IFocusable
Description
A button is essential to any user interface. The ButtonComponent makes use of the UnityEngine.UI.Button under the hood for integrated functionality for most user interactions.
Implementing IStylable<ButtonComponent, ButtonStyle> also allows for easy and reusable styling of your button.
With the Button inheriting from the Label, this means that all label styles are also applicable to the Button!
Examples
Simple UI Builder
UI.Button("Click me!", () => {
// ... execute code on click of the button
});
The button also supports and optional label call which allows for initialization with
an image:
Label Builder
UI.Button(() => {
// ... action
}, label => {
label.Label("Click me!", _pointerSprite);
})
.Style(LabelStyle.IconOnly); // inhertied support for label styles
.Padding(20); // apply padding of 20 to all sides