New answers tagged design-patterns
You can use my singleton class. It is a singleton MonoBehaviour. Use it by extending it: public class MyClass : MonoBehaviour<MyClass> The most current version is available on GitHub, but here is the current version of it: using System.Text.RegularExpressions; using UnityEngine; /// <summary> /// Extending this class creates a MonoBehaviour ...
There is actually a pseudo official way to use Singleton in Unity. Here is the explanation, basically create a Singleton class and make your scripts inherit from that class.
I wrote a singleton class that makes easy to create singleton objects. Its is a MonoBehaviour script, so you can use the Coroutines. Its based on this Unity Wiki article, and I will add option to create it from Prefab later. So you don't need to write the Singleton codes. Just download this Singleton.cs Base Class, add it to your project, and create your ...
Top 50 recent answers are included