架构大更

This commit is contained in:
SoulliesOfficial
2026-03-20 11:56:50 -04:00
parent e60ef64d01
commit d09b58fd80
3663 changed files with 15232012 additions and 105579 deletions

View File

@@ -0,0 +1,35 @@
using UnityEngine;
namespace SLSFramework.General
{
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
protected static T instance;
public static T Instance => instance;
protected virtual void Awake()
{
Initialize(false);
}
protected virtual void Initialize(bool dontDestroy)
{
if (dontDestroy)
{
if (instance == null)
{
instance = this as T;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}
else
{
instance = this as T;
}
}
}
}