2024-05-01 00:28:48 +08:00
|
|
|
using System.Collections;
|
2024-04-30 17:39:50 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T>
|
|
|
|
{
|
|
|
|
protected static T _instance = null;
|
|
|
|
|
|
|
|
public static T Instance { get => _instance; private set => _instance = value; }
|
|
|
|
|
|
|
|
protected void Awake()
|
|
|
|
{
|
|
|
|
if (Instance == null)
|
|
|
|
{
|
|
|
|
Instance = (T)this;
|
|
|
|
//DontDestroyOnLoad(gameObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|