Unity Game Session MVP

This commit is contained in:
Le Duc Anh
2025-09-08 16:28:54 +07:00
parent b75c818a1b
commit e3e435d12e
31 changed files with 2776 additions and 5 deletions
@@ -0,0 +1,38 @@
using UnityEngine;
namespace BrewMonster
{
public class MonoSingleton<T> : MonoBehaviour where T : MonoBehaviour
{
private static T _instance;
public static T Instance
{
get
{
if (_instance == null)
{
_instance = FindFirstObjectByType<T>();
if (_instance == null)
{
GameObject obj = new GameObject(typeof(T).Name);
_instance = obj.AddComponent<T>();
}
}
return _instance;
}
}
protected virtual void Awake()
{
_instance = this as T;
Initialize();
}
/// <summary>Override this method to initialize the singleton</summary>
protected virtual void Initialize()
{
}
}
}