FactorableDataDrawer

Generic Odin property drawer for all FactorableData-derived types. Renders data records in a foldable box with a "Factory Data" header and proper indentation for nested fields.

Definition

Namespace: Paragon.Core.ScriptableFactory.Editor Assembly: Paragon.Editor.dll

[DrawerPriority(0.0, 0.0, 3000.0)]
[JetBrains.Annotations.UsedImplicitly]
public class FactorableDataDrawer<TData> : OdinValueDrawer<TData>
    where TData : FactorableData

Inherits: OdinValueDrawer<TData> (Sirenix.OdinInspector.Editor) Type Constraint: TData : FactorableData Attribute: [DrawerPriority(0.0, 0.0, 3000.0)]

Remarks

This drawer automatically handles all FactorableData subclasses via the generic constraint. It draws each child property of the data record in a consistent box layout with:

  • A foldable header labeled either from the parent property's label or "Factory Data" as default

  • Each data field rendered inside a horizontal toolbar with indentation from GetCurrentDrawerIndentation()

  • Animated collapse/expand via SirenixEditorGUI.BeginFadeGroup

The drawer starts expanded by default (isExpanded = true in Initialize()).

Quick Lookup

Goal
How

Default label

"Factory Data" (when no label is provided by parent property)

Override for specific data type

Subclass with higher DrawerPriority (> 3000)

Starts expanded

Yes — isExpanded is true by default

Fields

Field
Type
Description

defaultLabel

GUIContent

Fallback label: "Factory Data"

isExpanded

bool

Foldout expansion state (defaults to true)

Methods

Initialize

Sets isExpanded to true.

DrawPropertyLayout

Main draw method. Renders the data record in a box with a foldable header. Iterates over all child properties and delegates to DrawDataField().

Parameter
Type
Description

label

GUIContent

Label from parent property. Falls back to defaultLabel if null.

DrawDataField (private)

Draws a single data field inside a horizontal toolbar with indentation support.

Extension Points

Optional Overrides

Method
Purpose

Initialize()

Custom setup (call base.Initialize() first)

DrawPropertyLayout(GUIContent)

Replace or extend the full draw logic

Implementation Requirements

When subclassing FactorableDataDrawer<TData>, you MUST:

  1. Use a higher DrawerPriority than 3000 (otherwise Odin will pick this drawer instead)

  2. Constrain TData to your specific FactorableData subclass

You SHOULD:

  • Call base.DrawPropertyLayout(label) if you want to extend (not replace) the rendering

  • Mark the subclass with [JetBrains.Annotations.UsedImplicitly] to suppress unused warnings

Examples

Custom Data Drawer

See Also

Last updated