Files
the-peoples-messenger/Assets/Scripts/Utils/Singleton.cs
T
2026-08-24 13:53:58 +01:00

21 lines
466 B
C#

using UnityEngine;
namespace Utils
{
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)
{
Destroy(gameObject);
return;
}
Instance = this as T;
DontDestroyOnLoad(gameObject);
}
}
}