IndieGame/client/Assets/Ether/Scripts/Common/Singleton/SingletonForMono.cs

26 lines
774 B
C#
Raw Normal View History

2024-10-11 10:12:15 +08:00
/********************************************************************
: SingletonForMono.cs
:
: 1982614048@qq.com
: 2024/03/29 17:28:19
:
: 2024/04/03 16:06:20
: Mono单例(mono的单例需自己保证唯一性)
*********************************************************************/
using UnityEngine;
public class SingletonForMono<T> : MonoBehaviour where T : MonoBehaviour
{
private static T m_instance;
public static T Inst { get => m_instance; }
private void Awake()
{
m_instance = this as T;
Init();
Debug.Log("初始化" + this.GetType().Name + "成功!");
}
protected virtual void Init() { }
}