IndieGame/client/Assets/Ether/Scripts/Common/Singleton/SingletonForMono.cs
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

26 lines
774 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/********************************************************************
文件: 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() { }
}