Auto Singleton

The simplest singleton tool on the Asset Store. Add the [Singleton] attribute to any class and the asset handles everything: automatic asset generation, cleanup, and polymorphic access at runtime.
Features
- Attribute-based setup: decorate any
MonoBehaviourorScriptableObjectwith[Singleton]: no base classes, no boilerplate; optionalinherited,displayName, andfolderPatharguments for fine-grained control - Automatic asset management: the editor creates and maintains prefabs (MonoBehaviour) or ScriptableObject assets after each compilation; deleting a singleton class also deletes its asset
- Polymorphic access: retrieve all singletons assignable to a type via
Singleton<T>.Instances;Tcan be a base class or an interface - Instance selection: designate which instance
Singleton<T>.Instancereturns usingSelectInstance: by predicate, priority function, runtime type, direct reference, or no-arg when only one is registered - Safe access helpers:
HasInstanceandTryGetInstancelet you check availability without catching exceptions;Findreturns all instances matching a predicate - Manual registration: use
Singleton.AddandSingleton.Removeat runtime to manage singletons of any reference type, not just Unity objects - No reload on play mode: works seamlessly with Unity’s no-domain-reload setting
- Editor tooling: Top Bar menu with force-refresh, automatic refresh, change logging, and project icon toggles; singleton list inspector to view and enable/disable each singleton individually
Content
- Singleton attribute:
SingletonAttributefor automatic asset management, withinherited,displayName, andfolderPathoptions - Runtime access classes:
Singleton(manualAdd/Remove) andSingleton<T>(Instance,Instances,HasInstance,TryGetInstance,Find,SelectInstance) - Editor tooling: automatic refresh system, singleton list inspector, project icons
- Demo: a Tic Tac Toe game built with MVC, demonstrating 5 singletons across
MonoBehaviour,ScriptableObject, and plain class types
Requirements
Unity 6.0 or later (tested up to 6.5)
Documentation
Get It
View on Unity Asset Store (Free)
Patch Notes
v1.2.0 June 5, 2026
Breaking Changes:
- The singleton list asset has been renamed to
Auto Singleton Listand moved fromAssets/Auto Singleton/Resources/toAssets/Resources/. Existing projects must move it manually, or delete it and let it be recreated on the next refresh. Singleton<T>.HasInstancenow throws outside of play mode, consistent withInstance. Previously it silently returnedfalse.Singleton<T>.SelectInstance(Predicate<T>)now correctly returnsfalsewhen no instance matches the predicate, instead of returningtrueand silently clearing the selected instance.
New:
- Added
Singleton<T>.TryGetInstance(out T instance): a non-throwing alternative toInstancethat returnsfalsewhen no instance is available, safe in both editor and builds. SelectInstanceoverloads now log a warning in the editor when returningfalse, making misconfigured or missing setup easier to spot.- The
Instanceerror message when no instance was selected now includes the count of available instances and a hint to callSelectInstance(). - Newly created singleton assets are pinged in the Project window after a refresh.
- The
Auto Singleton Listasset is automatically recreated if accidentally deleted. - The
Auto Singletonroot GameObject is now created lazily on the first MonoBehaviour singleton instantiation. - The singleton list ordering is now deterministic, preventing spurious VCS diffs on the
Auto Singleton Listasset.
Bug Fixes:
- MonoBehaviour singleton components were not being saved to their prefab file correctly; they now are.
- Open generic MonoBehaviour subclasses (e.g.
class Foo<T> : MonoBehaviour) are no longer mistakenly treated as instantiable. - Singletons registered via
Singleton.Addno longer appear as stale entries in the inspector after re-entering play mode. SelectInstancewith a numeric priority no longer incorrectly reports a tie when a singleton’s priority value equalsint.MinValueorfloat.MinValue.- Singleton assets are now deleted through Unity’s asset pipeline, preventing stale references.
- The singleton icon now scales correctly with the Project window’s zoom level.
- Fixed path issues on Windows that could cause asset operations and the Documentation menu item to fail.
v1.1.0 January 23, 2026
- The tool now fully works with no reload on play mode enabled
- Can now add and remove singletons at runtime using new methods, Add and Remove, in the Singleton class
- Removed the Find method from the Singleton class (it still exists in the
Singleton<T>class) - Fixed a bug where singleton icons would not appear without an assembly reload
- Fixed a bug happening if you launched the project with compilation errors
- Demo and documentation modified to reflect those changes
v1.0.0 October 19, 2023
Initial release.