using UnityEngine;
///
/// Simple implementation of a singleton instance for any script.
///
public class Singleton where T : MonoBehaviour
{
///
/// Write-once, read-many object reference. Set this value at least
/// once and all objects will have access to it as a singleton.
///
public static T instance
{
get { return _instance; }
set { if (_instance == null) _instance = value; }
}
///
/// Returns true iff a singleton has been assigned for this class.
///
public static bool assigned
{
get { return instance != null; }
}
///
/// current object reference
///
private static T _instance = null;
}
///
/// Avoids unity compiler warning in Unity 2.5 and earlier.
///
public class Singleton {}