Logo
UI Elements

Radio Button

Keep one button selected within a group

Overview

Radio Button Group coordinates a set of Evo UI Buttons so only one is selected at a time. An optional indicator moves between the selected buttons.

Preview

Usage

Place the buttons under a shared parent and add Radio Button Group.

Assign Target Parent, or use the group’s own hierarchy.

Choose the initial selected index and whether deselection is allowed.

Connect On Selection Changed to the setting controlled by the group.


Tips

  • The indicator can size itself to the selected button. Adjust its direction, stretch, duration, and curve to match the layout.
  • Indices follow the collected button order. Call Initialize() after changing the hierarchy to collect the buttons again.

Public API

Use RadioButtonGroup in the Evo.UI namespace.

Fields

NameTypeDescription
selectedIndexintCurrent selected index; -1 means none.
allowDeselectionboolAllows an already selected button to be deselected.

Methods

NameParametersDescription
Initialize()NoneRebuilds the group.
SetButton()int indexSelects a button with animation and selection events enabled.
SetButton()int index, bool animate, bool invokeEvents = trueSelects a button with animation and event controls.
DeselectAll()NoneClears the selection.
GetButton()NoneGets the currently selected button. Returns Button.
GetButton()int indexGets the button at an index, or null if the index is invalid. Returns Button.
IsButtonSelected()int indexChecks whether the specified button is selected. Returns bool.
SetInteractable()bool interactableChanges input availability for the group.

Events

NameTypeDescription
onSelectionChangedUnityEvent<int>Invoked with the selected index.

Example

RadioButtonGroupExample.cs
using UnityEngine;
using Evo.UI;

public class RadioButtonGroupExample : MonoBehaviour
{
    [SerializeField] private RadioButtonGroup target;

    private void Start()
    {
        target.SetButton(0, false, false);
        target.onSelectionChanged.AddListener(index => Debug.Log($"Selected {index}"));
    }
}

On this page