Factory

The Factory subsystem defines the core factory abstraction for the Scriptable Factory system. It provides a three-tier hierarchy of interfaces and abstract classes that handle object lifecycle (instantiate, spawn, despawn, destroy), object pooling, and data-driven variant spawning.

Architecture

spinner

Key Concepts

Concept
Description

Three-tier hierarchy

Each tier adds capability: base (lifecycle) → single-generic (pooling) → double-generic (data + variants).

Object pooling

ScriptableFactory<TObject> manages a FactorablePool for efficient spawn/despawn without allocation.

Data variants

ScriptableFactory<TObject, TData> supports a DataVariantSystem with DataOverride for spawning objects with different configurations from the same factory.

ScriptableObject-based

Factories are ScriptableObject assets, configured in the Inspector and discovered by the ScriptableFactoryRegistry.

IFactorable contract

All spawned objects must implement IFactorable (or IFactorable<TData> for data-driven objects).

Object Lifecycle

spinner

Quick Start

Creating a Simple Factory (No Data)

Creating a Data-Driven Factory

Spawning Objects

Classes

Class
Description

Interface hierarchy defining the factory contract

Abstract base — lifecycle and GameObject management

ScriptableFactory<TObject>

Single-generic — pooling, spawn/despawn, lifecycle hooks

ScriptableFactory<TObject, TData>

Double-generic — data variants, data-driven spawning

See Also

Last updated