UI Elements
Selector A sliding content selector
Selector displays a set of label or icon based items and allows switching between them using previous and next buttons. It is an alternative to a dropdown, and it is recommended to use it only with a small number of items. Navigating a large number of items with this component would not be good UX.
This component is ideal for option pickers, profile selectors, difficulty selection, color or preset cycling, or any situation where users choose among a small list of items.
Name Type Description selectedIndexintIndex of the currently selected item itemsList<Item>List of selectable items
Item
Field Type Description labelstringDisplayed label iconSpriteOptional icon onItemSelectionUnityEventFired when this item becomes selected
Name Type Description loopboolWraps around when reaching ends invokeAtStartboolTriggers selection events on Start
Name Type Description isHorizontalboolSlides left or right when true invertAnimationDirectionboolReverses animation direction slideOffsetfloatDistance used for slide animation animationDurationfloatTotal time for slide out and in animationCurveAnimationCurveCurve for easing transitions
Name Type Description selectedIndicatorAlphafloatAlpha for active indicator dot unselectedIndicatorAlphafloatAlpha for inactive dots indicatorFadeDurationfloatDuration for transitioning indicator alpha
Name Type Description contentParentRectTransformThe sliding content area contentCanvasGroupCanvasGroupFade control for content textObjectTextMeshProUGUIDisplays current item label iconObjectImageDisplays current item icon indicatorParentRectTransformParent for indicator dots indicatorPrefabGameObjectPrefab for each indicator dot prevButtonButtonButton for moving to previous item nextButtonButtonButton for moving to next item
Name Type Description onSelectionChangedUnityEvent<int>Fired when new item is selected
Name Parameters Description SetSelection(index, animated)int, boolSelects item at index with optional animation SetSelection(index)intSelects item with animation SelectNext()None Moves forward SelectPrevious()None Moves backward AddItem(item)ItemAdds new item AddItem(label, icon)string, SpriteAdds item with label and optional icon RemoveItem(index)intRemoves item ClearItems()None Resets all content
using UnityEngine ;
using Evo . UI ;
public class SelectorExample : MonoBehaviour
{
public Selector selector ;
void Start ()
{
// Add items
selector. AddItem ( "Easy" );
selector. AddItem ( "Normal" );
selector. AddItem ( "Hard" );
// Listen for changes
selector.onSelectionChanged. AddListener ( index =>
{
Debug. Log ( "Selected: " + selector.items[index].label);
});
// Select specific item
selector. SetSelection ( 1 );
// Move next and previous
selector. SelectNext ();
selector. SelectPrevious ();
}
}