Files
2026-03-04 10:03:45 +08:00

21 lines
368 B
C#

using UnityEngine;
namespace RootMotion
{
public abstract class Singleton<T> : MonoBehaviour where T : Singleton<T>
{
private static T sInstance;
public static T instance => sInstance;
protected virtual void Awake()
{
if (sInstance != null)
{
Debug.LogError(base.name + "error: already initialized", this);
}
sInstance = (T)this;
}
}
}