ParagonObject

Abstract base class for non-Unity serializable objects in the Paragon framework. Provides a manual Initialize()/Destroy() lifecycle, automatic debug system registration, and IDisposable support for deterministic cleanup.

Definition

Namespace: Paragon Assembly: Paragon.dll

[Serializable]
public abstract class ParagonObject : IDisposable, IDebugObject

Implements: System.IDisposable, IDebugObject

Remarks

ParagonObject is the base for any Paragon object that is not a Unity Object (not a MonoBehaviour or ScriptableObject). It provides the same debug registration pattern as ParagonBehaviour but with an explicit Initialize()/Destroy() lifecycle instead of Unity's OnEnable()/OnDisable().

Both ParagonSubsystem and ParagonComponent<T> inherit from this class.

The IDisposable.Dispose() implementation delegates to Destroy(), enabling using statements and integration with disposal patterns.

Quick Lookup

Goal
How

Create and initialize

obj.Initialize()

Destroy and clean up

obj.Destroy()

Use with using

using (var obj = ...) { } — calls Destroy() on dispose

Enable debug rendering

obj.DebugEnabled = true then override OnDebug()

Properties

DebugEnabled

Controls whether OnDebug() is called by the debug system each frame.

Methods

Initialize

Registers the object with the debug system. Subclasses should call base.Initialize() first.

Calls Debug.Register(this) to opt into the per-frame debug loop.

Destroy

Unregisters from the debug system and calls OnDestroy() for subclass cleanup.

Not virtual — cleanup logic goes in OnDestroy().

OnDestroy

Override point for subclass-specific cleanup logic. Called by Destroy().

OnDebug

Override point for debug rendering. Called each frame by the debug system when DebugEnabled is true.

circle-info

Debug.Register() and Debug.Unregister() are decorated with [Conditional("DEBUG_ENABLED")]. In release builds without that define, registration is a no-op and OnDebug() is never called.

Extension Points

Optional Overrides

Method
Purpose

Initialize()

Custom initialization — call base.Initialize() first

OnDestroy()

Cleanup on destruction

OnDebug()

Per-frame debug rendering (gizmos, logging)

Implementation Requirements

When subclassing ParagonObject, you MUST:

  1. Call base.Initialize() if overriding Initialize() — this registers with the debug system

  2. Call Destroy() when the object is no longer needed — or use IDisposable/using

You SHOULD:

  • Override OnDestroy() for cleanup instead of overriding Destroy()

  • Keep OnDebug() lightweight — it runs every frame when enabled

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated