ParagonBehaviour

Abstract base class for all Paragon MonoBehaviours. Extends Odin's SerializedMonoBehaviour with an optional ParagonSubsystem slot for component-based composition and automatic registration with the Paragon debug system.

Definition

Namespace: Paragon Assembly: Paragon.dll

[Serializable]
public abstract class ParagonBehaviour : Sirenix.OdinInspector.SerializedMonoBehaviour, IParagonBehaviour

Inherits: Sirenix.OdinInspector.SerializedMonoBehaviourMonoBehaviour Implements: IParagonBehaviour, IDebugObject

Remarks

ParagonBehaviour is the standard base class for any MonoBehaviour in the Paragon framework. It provides three features on top of Unity's MonoBehaviour:

  1. Odin serialization — inheriting from SerializedMonoBehaviour enables polymorphic serialization, dictionary fields, interfaces in Inspector, and other Odin features.

  2. Subsystem slot — an optional ParagonSubsystem reference for attaching components via the composition pattern. Checked via HasSubsystem.

  3. Debug registration — automatically registers with Debug.Register() on OnEnable() and unregisters on OnDisable(), enabling per-frame OnDebug() callbacks when DebugEnabled is true.

Quick Lookup

Goal
How

Create a Paragon MonoBehaviour

Subclass ParagonBehaviour

Check for subsystem

behaviour.HasSubsystem

Access the subsystem

Cast to IParagonBehaviour and access .Subsystem

Enable debug rendering

behaviour.DebugEnabled = true, override OnDebug()

Properties

DebugEnabled

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

Serialized but hidden in Inspector ([HideInInspector]).

HasSubsystem

Whether this behaviour has a ParagonSubsystem assigned.

Subsystem

The attached ParagonSubsystem. Accessed via the IParagonBehaviour interface (explicit implementation).

Methods

OnEnable

Registers with the debug system. Override to add custom enable logic — always call base.OnEnable().

OnDisable

Unregisters from the debug system. Override to add custom disable logic — always call base.OnDisable().

OnDebug

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

Extension Points

Optional Overrides

Method
Purpose

OnEnable()

Custom enable logic — call base.OnEnable() first

OnDisable()

Custom disable logic — call base.OnDisable() first

OnDebug()

Per-frame debug rendering (gizmos, overlay text)

Implementation Requirements

When subclassing ParagonBehaviour, you MUST:

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

  2. Call base.OnDisable() if overriding OnDisable() — this unregisters from the debug system

You SHOULD:

  • Use [Serializable] on the class for proper serialization

  • Assign a ParagonSubsystem in the Inspector if your behaviour needs components

  • Use Odin serialization attributes ([OdinSerialize], [ShowInInspector]) for advanced Inspector features

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

Examples

Basic behaviour

Behaviour with subsystem

See Also

Last updated