Files
Ultimate-Fishing-Simulator-…/Assets/Scripts/Assembly-CSharp/RootMotion/Singleton.cs
2026-03-04 09:37:33 +08:00

26 lines
427 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;
public static void Clear()
{
sInstance = null;
}
protected virtual void Awake()
{
if (sInstance != null)
{
Debug.LogError(base.name + "error: already initialized", this);
}
sInstance = (T)this;
}
}
}