From a13f10139d33264fc9ebc5a15c75faf16fc7757e Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Jul 2021 18:47:37 +0800 Subject: +Action Tool --- Assets/Scripts/Utils/Singleton.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Assets/Scripts/Utils') 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 : 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 where T : class, new() { private static T _instance; -- cgit v1.1-26-g67d0