FirstComit

This commit is contained in:
2026-05-13 14:47:38 +09:00
parent a1288e1696
commit 6d37110cf3
115 changed files with 44236 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using UnityEngine;
public abstract class SingletonMonoBehavior<T> : MonoBehaviour where T : SingletonMonoBehavior<T>
{
private static T _instance;
public static T Instance
{
get
{
if (_instance == null)
{
_instance = FindFirstObjectByType<T>();
if (_instance == null)
{
var go = new GameObject(typeof(T).Name);
_instance = go.AddComponent<T>();
}
}
return _instance;
}
}
protected virtual void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(gameObject);
return;
}
_instance = (T)this;
DontDestroyOnLoad(gameObject);
}
}