summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Utils/Singleton.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-07-07 18:47:37 +0800
committerchai <chaifix@163.com>2021-07-07 18:47:37 +0800
commita13f10139d33264fc9ebc5a15c75faf16fc7757e (patch)
tree9d6c40a21fc873c6e25ff4bbdeba663a73927427 /Assets/Scripts/Utils/Singleton.cs
parent1bb4971cffac3851a119f16e815bfe42abfc2df6 (diff)
+Action Tool
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;