diff options
Diffstat (limited to 'Assets/Scripts/Utils')
-rw-r--r-- | Assets/Scripts/Utils/Singleton.cs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Assets/Scripts/Utils/Singleton.cs b/Assets/Scripts/Utils/Singleton.cs index bdec31d3..a882238a 100644 --- a/Assets/Scripts/Utils/Singleton.cs +++ b/Assets/Scripts/Utils/Singleton.cs @@ -4,6 +4,21 @@ using UnityEngine; using System;
+public class SingletonMB<T> : MonoBehaviour where T : class
+{
+ protected static T s_Instance;
+ public static T Instance
+ {
+ get { return s_Instance; }
+ }
+
+ protected virtual void Awake()
+ {
+ s_Instance = gameObject.GetComponent(typeof(T)) as T;
+ }
+
+}
+
public class Singleton<T> where T : class, new()
{
private static T _instance;
|