DataFieldOverrideDrawer
Odin property drawer for DataFieldOverride. Renders the override's value using its child Value property and appends a red delete button that removes the override from its parent DataOverride dictionary.
Definition
Namespace: Paragon.Core.ScriptableFactory.Editor
Assembly: Paragon.Editor.dll
[DrawerPriority(0.0, 0.0, 3000.0)]
public class DataFieldOverrideDrawer : OdinValueDrawer<DataFieldOverride>Inherits: OdinValueDrawer<DataFieldOverride> (Sirenix.OdinInspector.Editor)
Remarks
This is the leaf-level drawer in the variant editor hierarchy. Each instance renders a single field override value alongside a trash icon button for removal. It is drawn by DataOverrideDrawer for each entry in the fieldOverrides dictionary.
The drawer consists of two horizontal sections:
Value field — The
Valuechild property is drawn using its own Odin drawer (which adapts to the field's actual type —float,int,string, etc.). Indentation from the property tree is respected.Delete button — A small red trash icon button (17 x 18 px) that, when clicked, finds the parent
fieldOverridesdictionary and removes the current override by itsFieldName.
Quick Lookup
Edit an override value
Modify the value field directly in the Inspector
Remove an override
Click the red trash icon button
Fields
dataFieldOverride
Cached reference to the DataFieldOverride instance being drawn.
valueProperty
Cached reference to the Value child property of the DataFieldOverride.
Methods
Initialize
Caches the DataFieldOverride reference from ValueEntry.SmartValue and resolves the Value child property.
DrawPropertyLayout
Main entry point called by Odin. Draws the value field and delete button in a horizontal toolbar.
label
GUIContent
Label provided by the parent drawer (typically the field name from DataOverrideDrawer).
Behavior:
Opens a horizontal toolbar layout.
Checks indentation via
valueProperty.GetCurrentDrawerIndentation()and applies spacing.Draws the
Valueproperty with the provided label inside a vertical layout.Calls
DrawControls()to render the delete button.
DrawControls
Draws the red trash icon button. On click, traverses up the property tree to find the fieldOverrides dictionary and removes the current override by FieldName.
Behavior:
Colorizes the button background red via
DrawGUI.ColorizeBackground(Color.red).Uses
FindParentWithName("fieldOverrides")to locate the owning dictionary.Casts the dictionary to
Dictionary<string, DataFieldOverride>and callsRemove(dataFieldOverride.FieldName).
Common Pitfalls
Parent property traversal
The delete button relies on FindParentWithName("fieldOverrides") to locate the owning dictionary. If the property tree structure changes (e.g., wrapping DataOverride in a custom container), this traversal may fail to find the parent.
Direct dictionary mutation
The delete operation directly mutates the fieldOverrides dictionary via Remove(). Odin detects this change and refreshes the property tree, but the removal is not undoable via Unity's Undo system.
See Also
DataFieldOverride — runtime class this drawer renders
DataOverrideDrawer — parent drawer that renders this
DataFieldOverrideSelectMenu — popup menu for adding new overrides
Variant Editor — editor subsystem overview
Last updated