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 : FactorableDataInherits: ParagonDrawer<FactorableSpawner<TObject, TData>> → OdinValueDrawer<FactorableSpawner<TObject, TData>> Implements: IDisposable Type Constraints:
TObject : class, IFactorable<TData>TData : FactorableDataAttribute:[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:
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.
Data preview — Reads the factory's
FactorableDatafor 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
DataOverrideFields marked
[Overridable]can be toggled; others are always read-only
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
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
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.
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
Null spawner auto-creation If the serialized FactorableSpawner field is null, the drawer auto-creates one in Initialize(). This means the first Inspector draw triggers a serialization change. If this is unexpected, ensure the spawner field has a default value in the declaring class.
Override checkbox clears bake Toggling a field override calls factorableSpawner.ClearBake(), invalidating cached spawn data. This is correct behavior — the next Spawn() call will re-bake with the updated overrides.
Same factory re-selection is ignored OnFactorySelected() returns early if the selected factory equals the current factory. This prevents unnecessary state clearing but means re-selecting the same factory cannot be used to "reset" the spawner.
Data property tree disposal The drawer implements IDisposable to clean up the PropertyTree created for factory data. If the drawer is not properly disposed (e.g., due to Odin lifecycle issues), the property tree may leak. The null-conditional ?.Dispose() guards against double-dispose.
See Also
FactorableSpawner — runtime spawner class this drawer renders
ScriptableFactorySelector — factory picker popup used in the header
DataOverride — field override system controlled by the checkboxes
FactorableData — data records rendered in the data preview
Spawner Editor — subfolder overview
Editor Overview — editor tooling overview
Last updated