void Awake() { //if theres another instance (there shouldnt be) destroy this.. THERE CAN BE ONLY ONE if (Instance != null && Instance != this) { //destroy all other instances Destroy(gameObject); } //set the instance Instance = this; //prevents this object being destroyed between scene loads //DontDestroyOnLoad(this.gameObject); }
void Awake() { //if theres another instance (there shouldnt be) destroy this.. THERE CAN BE ONLY ONE if(Instance != null && Instance != this) { //destroy all other instances Destroy(gameObject); } //set the instance Instance = this; //prevents this object being destroyed between scene loads //DontDestroyOnLoad(this.gameObject); }