additional package setup

This commit is contained in:
2025-11-16 18:31:17 -05:00
parent 3da42beb46
commit 2ca8077013
55 changed files with 1746 additions and 12 deletions

View File

@@ -0,0 +1,40 @@
using UnityEngine;
namespace Boxfriend.Utils
{
public abstract class SingletonBehaviour<T> : MonoBehaviour where T : SingletonBehaviour<T>
{
private static T _instance;
[SerializeField] protected bool _dontDestroy;
public static T Instance
{
get
{
if( _instance == null )
{
var go = new GameObject(typeof(T).Name);
go.AddComponent<T>();
}
return _instance;
}
private set
{
if (_instance == null)
_instance = value;
else if (value != _instance)
Destroy(value.gameObject);
}
}
protected virtual void __internalAwake ()
{
Instance = (T)this;
if(_dontDestroy)
DontDestroyOnLoad(gameObject);
}
}
}