21 lines
314 B
C#
21 lines
314 B
C#
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;
|
|
}
|
|
}
|