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:

  1. Field override list — Iterates the fieldOverrides dictionary property and draws each entry using DataFieldOverrideDrawer, labeling each with its FieldName.

  2. 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

Goal
How

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.

Parameter
Type
Description

label

GUIContent

Label from the serialized property (unused in this drawer).

Behavior:

  1. If FieldOverrideCount > 0, calls DrawFieldOverrides() to render all active overrides.

  2. 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.

Parameter
Type
Description

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 DataFieldOverride and uses FieldName as the GUIContent label.

  • Each entry is drawn by DataFieldOverrideDrawer via Odin's drawer resolution.

Common Pitfalls

circle-exclamation

See Also

Last updated