Repository navigation
ThreeStatesToggle
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).
GameObject → UI (Canvas) → Three States Toggle - Mane Tools instantiates the packaged prefab under a Canvas (UICanvasTools.PlaceUIElement) and starts Hierarchy rename.
The custom inspector includes Editor Tools (mode, wrap-around, explicit targets, Visualize).
Screenshot:
three-states-toggle.png— same control in on / off / undefined in the scene. Host athttps://raw.githubusercontent.com/wiki/ManeFunction/ManeTools-UnityUI/three-states-toggle.png.
openupm add com.manefunction.tools-unity-ui