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:

  1. Value field — The Value child 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.

  2. Delete button — A small red trash icon button (17 x 18 px) that, when clicked, finds the parent fieldOverrides dictionary and removes the current override by its FieldName.

Quick Lookup

Goal
How

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.

Parameter
Type
Description

label

GUIContent

Label provided by the parent drawer (typically the field name from DataOverrideDrawer).

Behavior:

  1. Opens a horizontal toolbar layout.

  2. Checks indentation via valueProperty.GetCurrentDrawerIndentation() and applies spacing.

  3. Draws the Value property with the provided label inside a vertical layout.

  4. 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 calls Remove(dataFieldOverride.FieldName).

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated