void Awake() { if (StaticObject == null) { StaticObject = this; DontDestroyOnLoad(this); } else if (this != StaticObject) { Destroy(gameObject); } }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { AudioBackground.instance = this; } DontDestroyOnLoad(this.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);//Makes sure multple of this gmaeobject dont spawn when moving between scenes } DontDestroyOnLoad(this.gameObject); }