private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { UnityEngine.Object.Destroy(this); return; } this.Setup(); }
void Awake() { if (instance == null) { instance = this; } else { if (instance != this) { Destroy(this); // remove self, but don't destroy the gameobject its attached to. i.e. don't kill the host object. return; } } Setup(); }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { if (instance != this) { Destroy(gameObject); return; } } Setup(); }