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() and Factory.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

Goal
How

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

Field
Type
Description

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.

Parameter
Type
Description

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 GameObject in 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

circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated