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 : AttributeInheritance: Attribute → SingletonSettingsAttribute
Quick Lookup
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)
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
InitializeOnLoad
✅
✅
✅
DontDestroyOnLoad
✅
—
—
HideInHierarchy
✅
—
—
HideInInspector
✅
—
—
AssetPath
✅
✅
—
Common Pitfalls
Attribute inheritance All singleton base classes have [SingletonSettings] with default values. Concrete subclasses should apply their own [SingletonSettings] to override. The system reads the attribute using GetCustomAttributes(..., true) (inherited), so the most-derived attribute takes precedence.
AssetPath without a Resources folder If AssetPath is set but the corresponding Resources/ directory doesn't exist, Resources.Load() returns null and the singleton falls through to CreateSingleton(). In the editor, auto-creation will fail if the target directory doesn't exist.
Examples
Minimal Configuration
Full Configuration
See Also
SingletonBehaviour<T> — reads all fields
SingletonScriptableObject<T> — reads
AssetPathandInitializeOnLoadSingletonObject<T> — reads
InitializeOnLoadSingletonInitializer — reads
InitializeOnLoadSingletons Subsystem — subsystem overview
Last updated