Variant
Custom Unity Editor tooling for the Variant subsystem. Provides Odin property drawers and popup menus that enable designers to manage data variants, add/remove field overrides, and navigate between variants directly in the Unity Inspector.
Architecture
Editor Components
Property Drawer
Foldable variant system with add/remove and paginated navigation
Property Drawer
Renders field overrides list with "Add New Override" button
Property Drawer
Draws a single override value with a delete button
Popup Menu
—
Field picker popup for adding overrides from [Overridable] fields
Drawer Hierarchy
The editor drawers form a nested rendering chain, each responsible for one layer of the variant data model:
Key Patterns
Drawer Priority System
All variant drawers use [DrawerPriority(0, 0, 3000)] to take precedence over Odin's default drawers:
DataVariantSystemDrawer<TData>
(0, 0, 3000)
DataVariantSystem<TData>
DataOverrideDrawer
(0, 0, 3000)
DataOverride
DataFieldOverrideDrawer
(0, 0, 3000)
DataFieldOverride
Variant Navigation
DataVariantSystemDrawer provides paginated navigation through variants using left/right arrow buttons and a numeric index field. The currently selected variant's DataOverride is drawn below the navigation bar.
Field Override Lifecycle
Designer clicks "Add New Override" in
DataOverrideDrawerDataFieldOverrideSelectMenuopens, listing fields marked with[Overridable]that are not yet overriddenDesigner selects a field —
DataOverride.AddFieldOverride()is calledDataFieldOverrideDrawerrenders the new override with its value editor and a red delete buttonClicking the delete button removes the override from the
DataOverride.fieldOverridesdictionary
Bake Invalidation
When any override value changes in DataVariantSystemDrawer.DrawDataOverrides(), the drawer calls variantSystem.ClearBake() to invalidate cached variants, ensuring the next runtime access triggers a fresh bake.
Dependencies
Odin Inspector
OdinValueDrawer<T>, GenericSelector<T>, SirenixEditorGUI, InspectorProperty
Paragon.Editor
DrawGUI utility for layout, toolbars, colorization, and styling
UnityEditor
EditorGUILayout, EditorGUI, GUILayout
See Also
Variant — runtime variant subsystem
DataVariantSystem<TData> — runtime class managing variants
DataOverride — runtime override collection
DataFieldOverride — runtime single-field override
OverridableAttribute — attribute marking overridable fields
Factory Editor — editor tooling for the factory subsystem
Last updated