SingletonSettingsAttribute

Class-level attribute that configures singleton behavior. Applied to concrete singleton subclasses to control asset loading path, initialization timing, scene persistence, and hierarchy visibility. Read at runtime by the singleton base classes and by SingletonInitializer.

Definition

Namespace: Paragon Assembly: Paragon.dll

[AttributeUsage(AttributeTargets.Class)]
public class SingletonSettingsAttribute : Attribute

Inheritance: Attribute → SingletonSettingsAttribute

Quick Lookup

Goal
How

Auto-load from Resources

[SingletonSettings(AssetPath = "My Asset")]

Initialize before scene loads

[SingletonSettings(InitializeOnLoad = true)]

Persist across scenes

[SingletonSettings(DontDestroyOnLoad = true)]

Hide from hierarchy

[SingletonSettings(HideInHierarchy = true)]

Hide from inspector

[SingletonSettings(HideInInspector = true)]

Full configuration

[SingletonSettings(InitializeOnLoad = true, DontDestroyOnLoad = true, AssetPath = "Managers/MyManager")]

Fields

InitializeOnLoad

When true, the SingletonInitializer will eagerly access Instance during [RuntimeInitializeOnLoadMethod], ensuring the singleton exists before any scene code runs.

Default: false

DontDestroyOnLoad

When true, the singleton's GameObject is marked with DontDestroyOnLoad() during Awake(). Only applies to SingletonBehaviour<T>.

Default: false

HideInHierarchy

When true, the singleton's GameObject is hidden in the Hierarchy window. Only applies to SingletonBehaviour<T>.

Default: false

HideInInspector

When true, the singleton's component is hidden in the Inspector. Only applies to SingletonBehaviour<T>.

Default: false

AssetPath

The Resources-relative path for loading/saving the singleton asset. Used by SingletonBehaviour<T> (loads prefabs) and SingletonScriptableObject<T> (loads .asset files).

Default: null (no asset loading/saving)

circle-info

The path is relative to a Resources/ folder and should not include the file extension. For example, "Managers/GameManager" resolves to Resources/Managers/GameManager.prefab (for behaviours) or Resources/Managers/GameManager.asset (for ScriptableObjects).

Field Applicability

Field
SingletonBehaviour
SingletonScriptableObject
SingletonObject

InitializeOnLoad

DontDestroyOnLoad

HideInHierarchy

HideInInspector

AssetPath

Common Pitfalls

circle-exclamation
circle-exclamation

Examples

Minimal Configuration

Full Configuration

See Also

Last updated