This commit is contained in:
2025-10-31 15:31:34 +08:00
parent cf47a388ca
commit ad94eae693
316 changed files with 40772 additions and 89 deletions

View File

@@ -0,0 +1,24 @@
using UnityEngine;
public class SingletonBehaviour<T> : MonoBehaviour where T : MonoBehaviour
{
private static T _instance;
public static T Inst
{
get
{
if (_instance == null)
{
_instance = FindAnyObjectByType<T>();
if (_instance == null)
{
GameObject singletonObject = new GameObject(typeof(T).Name);
_instance = singletonObject.AddComponent<T>();
}
}
return _instance;
}
}
}