FactorablePoolDrawer
Odin property drawer for FactorablePool. Provides a runtime inspector view of the object pool with three collapsible lists (active, inactive, all) and interactive controls for instantiating, spawning, despawning, and destroying pooled objects.
Definition
Namespace: Paragon.Core.ScriptableFactory.Editor Assembly: Paragon.Editor.dll
[DrawerPriority(0.0, 0.0, 3000.0)]
[JetBrains.Annotations.UsedImplicitly]
public class FactorablePoolDrawer : OdinValueDrawer<FactorablePool>Inherits: OdinValueDrawer<FactorablePool> (Sirenix.OdinInspector.Editor) Attribute: [DrawerPriority(0.0, 0.0, 3000.0)]
Remarks
This drawer is play-mode only — in edit mode, it displays a message prompting the user to enter play mode. At runtime, it provides a complete pool management interface:
Controller bar — "Instantiate" and "Spawn" buttons that call
Factory.Instantiate()andFactory.Spawn()directly from the Inspector.Active Objects — collapsible list of all spawned objects, each with "Show" (frame in Scene View) and "Despawn" buttons.
Inactive Objects — collapsible list of all despawned/reusable objects, each with a "Destroy" button.
Pool — collapsible list of all objects (active + inactive).
For MonoBehaviour-based factorables, the "Show" button frames the object's GameObject in the Scene View. For non-MonoBehaviour factorables, a polymorphic object field is shown instead.
Quick Lookup
View pool state
Select a factory monitor in play mode
Instantiate a new object
Click "Instantiate" button
Spawn from pool
Click "Spawn" button
Frame an object in Scene View
Click "Show" on an active pool item
Despawn an active object
Click "Despawn" on an active pool item
Destroy a pooled object
Click "Destroy" on any pool item
Fields
factorablePool
FactorablePool
The pool instance being drawn
isExpanded
bool
Main foldout expansion state
activePoolLabel
GUIContent
Label: "Active Objects"
inactivePoolLabel
GUIContent
Label: "Inactive Objects"
poolLabel
GUIContent
Label: "Pool"
isActivePoolExpanded
bool
Active objects section foldout state
isInactivePoolExpanded
bool
Inactive objects section foldout state
isPoolExpanded
bool
Full pool section foldout state
Methods
Initialize
Caches the pool reference and initializes label GUIContent objects.
DrawPropertyLayout
Main draw method. Renders the pool in a foldable box. In edit mode, shows a placeholder message. In play mode, draws the controller bar and three pool sections.
label
GUIContent
Label from parent property. Falls back to "Factorable Pool" if null.
DrawControllers (private)
Draws the "Instantiate" and "Spawn" buttons in a centered horizontal toolbar.
DrawPool (private)
Draws a collapsible pool section with item count and individual pool item rows.
DrawPoolItem (private)
Draws a single pool item row. For MonoBehaviour factorables, shows a Unity object field with "Show" and "Despawn"/"Destroy" buttons. For non-MonoBehaviour factorables, shows a polymorphic object field.
Behavior:
"Show" button — frames the object's
GameObjectin the Scene View (disabled when not spawned)"Despawn" button — calls
factorable.Despawn()(disabled when not spawned)"Destroy" button — calls
factorable.Destroy()(always available)
Common Pitfalls
Edit mode shows no pool data The pool is only populated at runtime. In edit mode, the drawer shows a placeholder message. Do not attempt to read pool data outside play mode.
Collection modification during iteration The drawer uses EditorGUI.BeginChangeCheck() / EndChangeCheck() and breaks out of the loop when a change is detected (e.g., after clicking "Despawn" or "Destroy"). This prevents InvalidOperationException from modifying the pool collection while iterating.
Show button preserves selection The "Show" button temporarily changes Selection.activeGameObject to frame the object in the Scene View, then restores the previous selection. This is intentional — it allows framing without navigating away from the inspector.
See Also
FactorablePool — runtime pool class this drawer renders
IFactorable — interface for pooled objects
Pool Editor — subfolder overview
Editor Overview — editor tooling overview
Last updated