FactorableSpawnerDrawer

Generic Odin property drawer for FactorableSpawner<TObject, TData>. Provides a comprehensive spawner configuration UI with factory selection, data field preview with per-field override toggles, and variant navigation.

Definition

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

[DrawerPriority(DrawerPriorityLevel.SuperPriority)]
[JetBrains.Annotations.UsedImplicitly]
public class FactorableSpawnerDrawer<TObject, TData> : ParagonDrawer<FactorableSpawner<TObject, TData>>, IDisposable
    where TObject : class, IFactorable<TData>
    where TData : FactorableData

Inherits: ParagonDrawer<FactorableSpawner<TObject, TData>>OdinValueDrawer<FactorableSpawner<TObject, TData>> Implements: IDisposable Type Constraints:

  • TObject : class, IFactorable<TData>

  • TData : FactorableData Attribute: [DrawerPriority(DrawerPriorityLevel.SuperPriority)]

Remarks

This is the most complex drawer in the Scriptable Factory editor tooling. It renders the full spawner configuration in three sections:

  1. Header — A toolbar row with a foldout, a read-only object field showing the currently selected factory, and a "Select" button that opens a ScriptableFactorySelector popup.

  2. Data preview — Reads the factory's FactorableData for the selected variant and renders each field with:

    • The field value (read-only when not overridden, editable when overridden)

    • A checkbox toggle that enables/disables per-field overrides via DataOverride

    • Fields marked [Overridable] can be toggled; others are always read-only

  3. Variant selector — A side panel showing a ScriptableObject icon and left/right arrows for navigating between data variants (index 0 = source data).

The drawer creates a separate PropertyTree for the factory's data to render it inline without modifying the factory asset. It also auto-initializes the spawner if null and disposes the data property tree when the drawer is destroyed.

Quick Lookup

Goal
How

Select a factory

Click "Select" → pick from popup

Clear factory selection

Click "Select" → pick "None"

Override a data field

Check the checkbox next to the field

Navigate variants

Click left/right arrows in the variant panel

Current variant index

Shown as currentIndex/maxIndex in the variant panel

Properties

factorableSpawner (private)

Convenience accessor to the drawn FactorableSpawner via ParagonDrawer.target.

Fields

Field
Type
Description

scriptableFactory

IScriptableFactory<TObject, TData>

Currently selected factory reference

dataOverride

DataOverride

The spawner's field override configuration

factorySelector

ScriptableFactorySelector<TObject, TData>

Popup selector for picking a factory

isExpanded

bool

Main foldout expansion state (defaults to true)

factoryDataPropertyTree

PropertyTree

Odin property tree for the factory's data (for inline rendering)

scriptableFactoryProperty

InspectorProperty

Odin property for the scriptableFactory field

dataOverrideProperty

InspectorProperty

Odin property for the dataOverride field

fieldOverridesProperty

InspectorProperty

Odin property for dataOverride.fieldOverrides

Methods

Initialize

Sets up the drawer state: auto-creates the spawner if null, resolves Odin properties, creates the data property tree, and instantiates the factory selector.

circle-info

Auto-initialization. If the spawner field is null (e.g., first time the property is drawn), Initialize() creates a new FactorableSpawner<TObject, TData>() and applies the change to the serialized object.

DrawPropertyLayout

Main entry point. Draws the header, then (if a factory is selected and expanded) draws the data preview and variant selector side-by-side.

DrawHeader (private)

Draws the toolbar header with foldout, read-only factory object field, and "Select" button.

UpdateData (private)

Clamps the variant index and updates the data property tree to reflect the currently selected variant.

DrawData (private)

Iterates over the factory data's child properties and renders each via DrawDataField().

DrawDataField (private)

Draws a single data field with override support. If the field is overridden, draws the override's value (editable); otherwise, draws the factory's source value (read-only).

DrawControls (private)

Draws the override toggle checkbox for a data field. Checking the box calls dataOverride.AddFieldOverride(); unchecking calls RemoveFieldOverride() and ClearBake().

DrawVariantSelector (private)

Draws the variant navigation panel with left/right arrows and current index display.

OnFactorySelected (private)

Callback from the factory selector. Updates the spawner's factory reference, refreshes serialization, and creates a new data property tree.

Dispose

Disposes the data property tree to release resources.

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated