整合SLSUtilities

This commit is contained in:
SoulliesOfficial
2026-01-17 11:35:49 -05:00
parent d94241f36c
commit 7ee2894a63
1338 changed files with 3051541 additions and 507034 deletions

View File

@@ -0,0 +1,36 @@
using Sirenix.OdinInspector;
using UnityEngine;
namespace SLSFramework.General
{
public class Singleton<T> : SerializedMonoBehaviour 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;
}
}
}
}