Files
ZHGD_Web/Assets/Script/Tool/Singleton.cs

21 lines
314 B
C#
Raw Normal View History

2025-07-13 23:16:20 +08:00
using UnityEngine;
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
private static T _inst;
public static T Inst
{
get { return _inst; }
}
private void Awake()
{
_inst = this as T;
}
private void OnDisable()
{
_inst = null;
}
}