Object

The Object subsystem defines the factorable object contract — the types that a ScriptableFactory can instantiate, pool, spawn, and despawn. It provides three abstract base classes, one for each Unity object paradigm, plus the IFactorable interface they all implement.

Architecture

spinner

Choosing a Base Class

Base Class
Unity Type
Use When

MonoBehaviour

Object needs a GameObject with transforms, components, and scene presence

Plain C# object

Object is pure data/logic with no Unity scene representation

ScriptableObject

Object is an asset-like instance that lives outside the scene hierarchy

All three follow the same lifecycle and provide identical virtual method hooks. The only differences are in how Unity manages the underlying object (GameObject vs C# instance vs ScriptableObject).

Object Lifecycle

spinner

Lifecycle Details

Phase

What Happens

IsSpawned

FactorableBehaviour Specifics

Instantiate

Factory creates instance, calls OnInstantiate()

false

GameObject deactivated, parented to factory

Spawn

Factory activates instance, calls OnSpawn()

true

GameObject activated, unparented, moved to active scene

Despawn

Factory deactivates instance, calls OnDespawn()

false

GameObject deactivated, re-parented to factory

Destroy

Instance removed from pool

false

Object.Destroy(gameObject) called

Data-Driven Variants

Each base class has a generic variant (e.g., FactorableBehaviour<TData>) that adds data initialization via IFactorable<TData>:

Quick Start

Creating a Factorable MonoBehaviour

Despawning an Object (Self-Return to Pool)

Classes

Class
Description

Interface defining the factorable object contract

Abstract MonoBehaviour base for scene objects

Abstract C# object base for non-Unity instances

Abstract ScriptableObject base for asset-like instances

See Also

Last updated