Add utils + refacto

This commit is contained in:
2026-01-30 17:39:26 +01:00
parent 9ff17b5305
commit 23d3cb5d2c
29 changed files with 675 additions and 461 deletions
@@ -0,0 +1,33 @@
using UnityEngine;
namespace Unheimlich.Core
{
public abstract class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
public static T Instance { get; private set; }
protected virtual void Awake()
{
if (Instance != null && Instance != this)
{
Debug.LogWarning($"[{typeof(T).Name}] Multiple instances detected! Destroying duplicate on GameObject '{gameObject.name}'.");
Destroy(this);
return;
}
Instance = this as T;
OnAwake();
}
protected virtual void OnDestroy()
{
if (Instance == this)
{
Instance = null;
OnDestroyInstance();
}
}
protected virtual void OnAwake() { }
protected virtual void OnDestroyInstance() { }
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 654e642c73c2b954fa86e0caac3f08c1