DataOverrideDrawer
Odin property drawer for DataOverride. Renders the list of active field overrides and provides an "Add New Override" button that opens a DataFieldOverrideSelectMenu popup for selecting additional overridable fields.
Definition
Namespace: Paragon.Core.ScriptableFactory.Editor
Assembly: Paragon.Editor.dll
[DrawerPriority(0.0, 0.0, 3000.0)]
public class DataOverrideDrawer : OdinValueDrawer<DataOverride>Inherits: OdinValueDrawer<DataOverride> (Sirenix.OdinInspector.Editor)
Remarks
This drawer is rendered by DataVariantSystemDrawer for each variant's DataOverride. It has two responsibilities:
Field override list — Iterates the
fieldOverridesdictionary property and draws each entry using DataFieldOverrideDrawer, labeling each with itsFieldName.Add button — Renders a centered "Add New Override" button that opens the DataFieldOverrideSelectMenu popup, which lists all
[Overridable]fields not yet overridden.
The drawer exposes itself (this) to DataFieldOverrideSelectMenu via the constructor, allowing the menu to access the ValueEntry and mark the property tree dirty after adding an override.
Quick Lookup
Add a field override
Click "Add New Override" and select a field from the popup
Remove a field override
Click the red trash button on the individual override (handled by DataFieldOverrideDrawer)
Access the drawn DataOverride
ValueEntry.SmartValue
Fields
fieldOverridesProperty
Cached reference to the fieldOverrides child property (the Dictionary<string, DataFieldOverride>).
dataFieldOverrideSelectMenu
Instance of the field picker popup menu, created during Initialize().
Methods
Initialize
Caches the fieldOverrides child property and creates the DataFieldOverrideSelectMenu instance.
DrawPropertyLayout
Main entry point called by Odin. Draws the field override list (if any exist) followed by the "Add New Override" button.
label
GUIContent
Label from the serialized property (unused in this drawer).
Behavior:
If
FieldOverrideCount > 0, callsDrawFieldOverrides()to render all active overrides.Draws a centered "Add New Override" button (115 x 17 px, font size 11). On click, opens
dataFieldOverrideSelectMenu.Show(rect).
DrawFieldOverrides
Iterates each child of the fieldOverrides dictionary property, extracting the DataFieldOverride value and drawing it with its FieldName as the label.
fieldOverridesProperty
InspectorProperty
The Odin property representing the fieldOverrides dictionary
Behavior:
For each dictionary entry, accesses
Children[1](the value side of the key-value pair).Casts to
DataFieldOverrideand usesFieldNameas theGUIContentlabel.Each entry is drawn by DataFieldOverrideDrawer via Odin's drawer resolution.
Common Pitfalls
Dictionary child indexing
Odin serializes dictionary entries as key-value pairs. The drawer accesses Children[1] to get the value (DataFieldOverride), not Children[0] (the key string). This index is stable for Odin-serialized dictionaries.
See Also
DataOverride — runtime class this drawer renders
DataFieldOverrideDrawer — drawer for individual field overrides
DataFieldOverrideSelectMenu — popup menu for selecting fields to override
DataVariantSystemDrawer — parent drawer that renders this
Variant Editor — editor subsystem overview
Last updated