UnitySingleton icon indicating copy to clipboard operation
UnitySingleton copied to clipboard

The best way to implement singleton pattern in Unity.

Results 7 UnitySingleton issues
Sort by recently updated
recently updated
newest added

```c# protected virtual void Awake() { if (_instance == null) { _instance = this as T; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } } ``` The `Awake()` function is the key...

Thanks for the code, I believe it could be further enhanced to support editor mode, like the following: ``` using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; using UnityEngine; namespace Z { [PublicAPI] [ExecuteAlways]...

enhancement

Add Unity Package Manager setup instructions and include package.json file.

Hi, whenever I enter play mode and any of my script is trying to call something from singletons, whole unity crashes without any error log. Is there any limitations which...

All links that refers into examples are broken because Samples folder renamed into Samples~ for some reason. I dont know what intend to rename thus i will not make pr...

I think it's needed to unsubscribe from events in `OnDestroy` to prevent memory leaks, such as: ```cs private void OnDestroy() { if (StatsManager.Instance != null) { StatsManager.Instance.OnStatsChanged -= OnStatsChanged; }...

bug