This module is part of the Unity Essentials ecosystem and follows the same lightweight, editor-first approach. Unity Essentials is a lightweight, modular set of editor utilities and helpers that streamline Unity development. It focuses on clean, dependency-free tools that work well together.
All utilities are under the UnityEssentials namespace.
using UnityEssentials;
Install the Unity Essentials entry package via Unity's Package Manager, then install modules from the Tools menu.
-
Add the entry package (via Git URL)
- Window → Package Manager
- "+" → "Add package from git URL…"
- Paste:
https://github.com/EggyStudio/UnityEssentials.git
-
Install or update Unity Essentials packages
- Tools → Install & Update UnityEssentials
- Install all or select individual modules; run again anytime to update
Quick overview: Render boolean fields as clickable toggle buttons with optional icons. Group related toggles on one line by name.
Replace checkbox UI with compact buttons. Use [ToggleButton("iconName")] on a bool to draw a toolbar‑style button; use a shared groupName to render multiple bools as a labeled row of buttons. Icons can be referenced by name or via the EditorIconNames enum.
- Button UI for boolean fields (on/off state)
- Optional icon per button; tooltip comes from the field’s tooltip
- Grouping: render multiple toggles in a labeled row via a shared
groupName - Keyboard activation support (Enter/Space) when focused
- Editor‑only; zero runtime overhead
- Unity Editor 6000.0+ (Editor‑only; attribute lives in Runtime for convenience)
- Inspector Hooks module (for property iteration and keyboard focus helper)
- Editor Icons module (for
EditorIconUtilitiesandEditorIconNamesicon references)
Tip: To show a helpful tooltip on hover, add a [Tooltip("...")] to your field.
Single toggle with icon by name
using UnityEngine; using UnityEssentials; public class Example : MonoBehaviour { [Tooltip("Enable post effects")] [ToggleButton("scenevis_visible_hover@2x")] public bool postFX; }
Single toggle with icon enum
public class Example2 : MonoBehaviour { [ToggleButton(EditorIconNames.ToggleIcon)] public bool active; }
Grouped toggles on one row
public class RenderingModes : MonoBehaviour { [ToggleButton(EditorIconNames.ShaderIcon, groupName: "Rendering Modes")] public bool opaque; [ToggleButton(EditorIconNames.ShaderGraphIcon, groupName: "Rendering Modes")] public bool cutout; [ToggleButton(EditorIconNames.ShaderVariantCollectionIcon, groupName: "Rendering Modes")] public bool transparent; }
- Drawer supports
boolfields only; others show an inline error - Single: draws an optional label, then a 32×20 button showing the icon; clicking toggles the bool
- Grouped: finds all fields in the inspector with
[ToggleButton]sharing the samegroupName; draws them once as a labeled row of buttons - Icons are loaded via
EditorGUIUtility.IconContent(iconName); enum overload resolves to a string usingEditorIconUtilities - Tooltip is taken from the field’s tooltip (if provided)
- Keyboard activation uses the Inspector Hooks focus helper to simulate a click when focused
- Supported field type:
boolonly - Group rendering occurs only once (on the first field in the group) to avoid duplicates; this is automatic
- Icon references must exist; invalid names result in an empty button content
- Labels
- Single button: uses the field label
- Grouped row: uses the
groupNameas the row label
- Multi‑object editing supported; state toggles per inspected target
- Editor‑only: no effect at runtime
Runtime/ToggleButtonAttribute.cs– Attribute with icon reference (string orEditorIconNames) and optionalgroupNameEditor/ToggleButtonDrawer.cs– PropertyDrawer (single/grouped layout, icon/tooltip, keyboard, apply)Runtime/UnityEssentials.ToggleButtonAttribute.asmdef– Runtime assembly definitionEditor/UnityEssentials.ToggleButtonAttribute.Editor.asmdef– Editor assembly definition
unity, unity-editor, attribute, propertydrawer, toggle, button, toolbar, icon, group, inspector, ui, tools, workflow
