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