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