Skip to main content

Button and Toggle

YauiButton​

YauiButton invokes OnClick when it is clicked, or submitted with a gamepad or a keyboard.

Button YauiElement (the background), YauiButton
└─ Label YauiText
button.OnClick.AddListener(() => Debug.Log("Clicked"));

YauiToggle​

YauiToggle switches on and off when it is clicked or submitted. While it is on, it shows its Graphic (for example a checkmark), by driving the graphic's opacity.

Toggle YauiElement, YauiToggle
├─ Box YauiElement (the frame)
│ └─ Check YauiImage (the Graphic)
└─ Label YauiText
MemberDescription
IsOnWhether the toggle is on
GraphicThe element shown while on
ToggleTransitionFade fades the graphic in and out; None shows and hides it at once
GroupThe toggle group of this toggle, if any
OnValueChangedInvoked with the new value when it changes
SetIsOnWithoutNotify(value)Changes the value without invoking OnValueChanged

YauiToggleGroup​

A YauiToggleGroup makes its toggles exclusive, like radio buttons: switching one on switches the others off. Set the Group of each toggle to the group.

MemberDescription
AllowSwitchOffWhether clicking the toggle that is on switches it off, leaving none on
ActiveToggleThe toggle that is on, or null
TogglesThe toggles of the group
AnyTogglesOn()Whether a toggle is on
SetAllTogglesOff(notify)Switches all toggles off