Repository navigation
ThreeStatesToggle
Ilia Petrov-Komotskii edited this page Sep 30, 2026
·
6 revisions
Toggle with three states: on, off, and undefined. Click cycles on → off → undefined → on. State is bool? (true / false / null).

using Mane.Unity.UI;
using UnityEngine;
public class FilterRow : MonoBehaviour
{
[SerializeField] private ThreeStatesToggle _include;
private void OnEnable() => _include.StateValueChanged += OnChanged;
private void OnDisable() => _include.StateValueChanged -= OnChanged;
private void OnChanged(bool? value)
{
if (value == null)
ShowAll();
else
Filter(value.Value);
}
}Unity's Toggle.graphic is the on visual. Assign:
-
offGraphic— shown while off -
undefinedGraphic— shown while undefined
Alpha is faded (CrossFadeAlpha in play mode; instant in edit mode). Missing graphics are skipped.
-
onStateValueChanged—UnityEvent<bool?> -
StateValueChanged— same listeners as a C# event - Setting
isOnalso setsStateto true or false (never undefined). - Setting
StateupdatesisOn(true→ on;falseandnull→ off).
ToggleGroup is not supported (group is obsolete and throws).
Animation: if undefinedGraphic alpha is non-zero, state is treated as undefined (OnDidApplyAnimationProperties).
Control has a pre-defined composed control like standard Unity UI controls under GameObject → UI (Canvas) → Three States Toggle - Mane Tools.

openupm add com.manefunction.tools-unity-ui