UGTK / Toolkit / Ui Module / Toggle Extension Completed
Toggle Extension
Summary
Extends Unity's UI Toggle. Mn_UGTKToggle is a Toggle subclass that adds separate OnValueBecameTrue / OnValueBecameFalse events (with auto-binding of Background/Checkmark graphics), while Mn_MultiToggle aggregates several toggles as one controller, firing "all on" / "all off" and per-toggle edge events.
Content
Modules Dependencies
This module has no hard UGTK dependencies. It relies only on Unity UI (UnityEngine.UI.Toggle) and UnityEvents.
Setup
Drop the UGTK Toggle prefab under a Canvas (or MultiToggle for the aggregate controller):
Both are also reachable from the menus UGTK/UI/Mn Toggle Extended and UGTK/Utility/Toggle/Mn Multi Toggle As Single.
How To Use
- Use
Mn_UGTKTogglein place of a standardToggle(menu UGTK/UI/Mn Toggle Extended). WireOnValueBecameTrue/OnValueBecameFalsefor state-specific reactions; enableinvokeInEditModeto also fire in edit mode. It auto-bindstargetGraphic(Background) andgraphic(Checkmark) if left empty, and warns if multiple Toggle components share the GameObject. - Use
SetIsOnWithoutNotifyButFireExtended(bool)to change state silently for the base event but still fire the extended events. - Add
Mn_MultiToggle(menu UGTK/Utility/Toggle/Mn Multi Toggle As Single) and populate itstoggleslist. It firesonAllOn/onAllOffwhen every considered toggle is on/off, andonAnyTurnedOn(Toggle)/onAnyTurnedOff(Toggle)on individual transitions. Mn_MultiToggleis play-mode only, null-safe and de-duplicated; options includesuppressEventsOnFirstSyncandignoreInactiveToggles. Manage it at runtime viaSetToggles(...)andRefreshNoEvents().
Good to know:
Mn_UGTKTogglereplacesToggle, it does not sit next to it. It is a subclass: remove the stock Toggle and add this one — the component warns you when two Toggles share a GameObject.- The extended events fire after
Toggle.onValueChanged, so a listener on the base event runs first. Use the extended ones when you only care about one direction and want to stop writingif (isOn)in every handler. Mn_MultiToggleonly works in Play Mode and de-duplicates its list, skipping nulls. WithignoreInactiveToggleson, an inactive toggle does not count towards "all on" / "all off" — which is what you want for a panel that hides some options.suppressEventsOnFirstSync(on by default) prevents the aggregate events from firing on the very first evaluation, so a scene that starts with everything already on does not immediately triggeronAllOn.
Testing Scene
Open Debug/ToggleScene.unity and press Play: the extended toggle fires its became-true /
became-false events, and the multi-toggle reports all-on / all-off across the group.
Technical Info
- Mn_UGTKToggle:
Togglesubclass adding became-true/became-false UnityEvents, defensive listener hookup, and auto-binding of Background/Checkmark graphics. - Mn_MultiToggle: MonoBehaviour that subscribes to a list of Toggles (adding/removing only its own listeners) and raises aggregate all-on/all-off and per-toggle edge events.
© 2026 Marcello De Bonis. All rights reserved
Depends on 0
- Standalone: no other module required.
Used by 1
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 0 modules in total.
UGTKengine within an engine


