ScriptableFactory

Abstract base class for all factories in the Scriptable Factory system. Extends ParagonScriptableObject (Odin SerializedScriptableObject) and implements IScriptableFactory. Provides the standard lifecycle implementation — creating a root GameObject during initialization — and exposes virtual hooks for subclass customization.

Definition

Namespace: Paragon.Core.ScriptableFactory Assembly: Paragon.dll

[Serializable]
public abstract class ScriptableFactory : ParagonScriptableObject, IScriptableFactory

Inheritance: SerializedScriptableObjectParagonScriptableObject → ScriptableFactory Implements: IScriptableFactory

Remarks

ScriptableFactory is the non-generic root of the factory class hierarchy. It handles the minimal setup that every factory needs:

  • Creating a runtime GameObject named after the factory asset

  • Storing references to the GameObject and its Transform

The interface methods (Initialize, Start, OnQuit) are implemented as explicit interface calls that delegate to protected virtual methods, allowing subclasses to override them while keeping the public API clean.

This class is never subclassed directly in game code — use ScriptableFactory<TObject> or ScriptableFactory<TObject, TData> instead.

Quick Lookup

Goal
How

Create a factory without data

Subclass ScriptableFactory<TObject>

Create a data-driven factory

Subclass ScriptableFactory<TObject, TData>

Access runtime GameObject

factory.gameObject

Access runtime Transform

factory.transform

Properties

gameObject

The factory's runtime root GameObject, created during Initialize(). Spawned objects are typically parented under this transform.

transform

The Transform of the factory's root GameObject.

Extension Points

Optional Overrides

Method
Return Type
Called When
Purpose

Initialize()

void

Manager startup

One-time setup. Base creates the root GameObject.

Start()

void

After all factories initialized

Pre-warming, deferred setup. Base is empty.

OnQuit()

void

Application quit

Cleanup. Base is empty.

Lifecycle Flow

Implementation Requirements

When subclassing (indirectly via generic tiers), you MUST:

  1. Call base.Initialize() if you override Initialize() — it creates the root GameObject

You SHOULD:

  • Use [CreateAssetMenu] to make the factory easily creatable in the Unity Editor

  • Mark the class with [Serializable]

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

  • ScriptableFactory<TObject> — adds object pooling and lifecycle hooks

  • ScriptableFactory<TObject, TData> — adds data-driven variant spawning

  • IScriptableFactory — interface this class implements

  • Factory Subsystem — subsystem overview

Last updated