summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Utils/Singleton.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Utils/Singleton.cs')
-rw-r--r--Assets/Scripts/Utils/Singleton.cs15
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;