Skip to main content

Controls

YAUI includes the common controls of uGUI, rebuilt on YAUI elements:

ControlDescription
YauiButtonInvokes an event when clicked
YauiToggle, YauiToggleGroupOn/off switches, and radio buttons
YauiSliderPicks a value in a range
YauiScrollbarShows and changes a scroll position
YauiScrollViewScrolls content inside a viewport
YauiInputFieldEdits text, with IME and on-screen keyboards
YauiDropdownPicks one option from a list

Controls are components added next to a YauiElement. They do not draw anything themselves: build their look from elements, and link the parts (a handle, a fill, a label...) in the Inspector. The Controls sample has a ready-made example of each.

Controls need a YauiRaycaster on the panel and an EventSystem in the scene. See Input.

Selectables​

All controls except the scroll view derive from YauiSelectable, the equivalent of uGUI's Selectable. A selectable follows the pointer and the EventSystem's selection, and shows its state (Normal, Highlighted, Pressed, Selected or Disabled).

Interactable turns the control on and off. A control that is not interactable shows the Disabled state and ignores input.

Transitions​

A transition shows the state on the target element (TargetElement, or the selectable's own element when not set):

TransitionEffect
ColorTintMultiplies the colors of the target by the color of the state (YauiElement.Tint), fading over FadeDuration seconds
SpriteSwapDraws the sprite of the state on the target image (YauiImage.OverrideSprite)
AnimationSets the trigger of the state on the Animator of the selectable's GameObject
NoneNo effect

The color tint affects only the target element itself, not its children: tint a label separately if needed.

Selectables can be selected with a gamepad or a keyboard, through the move events of the EventSystem. Navigation sets how:

ModeBehavior
AutomaticMoves to the nearest selectable of the panel in the direction of the move
Horizontal, VerticalLike Automatic, on one axis only
ExplicitMoves to the selectables set for each direction (Up, Down, Left, Right)
NoneNo navigation

With WrapAround, moving past the last selectable in a direction selects the first one. In the automatic modes, the selectables set for a direction are used where they are set.

To select a control from a script, call Select().