void Awake() { if (instance == null) { instance = this; } else { DestroyImmediate(this); } }
void Awake() { if (singleton != null) { DestroyImmediate(gameObject); return; } singleton = this; DontDestroyOnLoad(gameObject); }
// Start is called before the first frame update void Awake() { if (instance != null) { Destroy(gameObject); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
void Awake() { //if we don't have an [_instance] set yet if (!_instance) { _instance = this; } //otherwise, if we do, kill this thing else { Destroy(this.gameObject); } DontDestroyOnLoad(this.gameObject); }