protected void Awake() { if (_instance == null) { // This is the first instance of the behaviour _instance = this; } else { // Log an error so developers can clean up their code Debug.LogFormat(TEXT_SINGLETON_EXISTS_ERROR, this.GetType().Name); // Destroy the entire game object this behaviour is attached to GameObject.Destroy(this.gameObject); } }
public K Get <T, K>(string smartPath = null) { SmartBehaviour obj = Get <T>(smartPath) as SmartBehaviour; return(obj.GetComponent <K>()); }