Let's see how good this highlighter is:

/// <summary>
/// Base manager class that inforces singleton pattern.
/// Your class should derive from this, not directly from the non-generic Manager.
/// </summary>
/// <typeparam name="T">Self</typeparam>
[Serializable]
public abstract class Manager<T> : Manager where T : Manager<T>
{
    private static T instance = null;

    public static T Instance
    {
        get 
        {
            if (instance == null)
                instance = ScriptableObject.CreateInstance<T>();

            return instance;
        }
    }

    protected Manager() { }

    /// <summary>
    /// Called when a deserialized version is loaded.
    /// </summary>
    public override void Deserialize()
    {
        instance = (T)this;
    }
}

 

Hmm... Yeah... Pretty good actually.

Write comment (0 Comments)