Files
butchers-games-test/Assets/Scripts/Toolkit/OHM/UnityToolkit/UniqueInstance_T.cs
T
Boris Nikolaev 5f1e94b653 add project files
2026-08-14 01:58:31 +03:00

37 lines
531 B
C#

using System;
using UnityEngine;
namespace OHM.UnityToolkit
{
public class UniqueInstance<T> : MonoBehaviour
{
private static UniqueInstance<T> _instance;
public static T Instance
{
get
{
return (_instance is T typed) ? typed : default(T);
}
}
public void Awake()
{
if (_instance != null)
{
Debug.LogWarning("There is more than one _instance of type " + typeof(T));
}
else
{
_instance = this;
}
AwakeInstance();
}
protected virtual void AwakeInstance()
{
}
}
}