void Awake() { indexScene = SceneManager.GetActiveScene().buildIndex; totalScenes = SceneManager.sceneCountInBuildSettings; middleScene = ((totalScenes - 2) / 2) + 2; Debug.Log("The actual Scene is: " + indexScene); if ((indexScene == middleScene || indexScene == 1 || indexScene == 0)) { Destroy(GameObject.Find("BG")); instance = null; } if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } }
private void Awake() { if (instance != null && instance != this) { UnityEngine.Object.Destroy(base.gameObject); return; } instance = this; Object.DontDestroyOnLoad(base.gameObject); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
void Start() { gameObject.GetComponent <AudioSource>().Play(); if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); if ((SceneManager.GetActiveScene().buildIndex == 7)) { Destroy(gameObject); } }
private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } Scene scene = SceneManager.GetActiveScene(); if (scene.name == "Main Menu") { DontDestroyOnLoad(this.gameObject); setNotDestroyed = true; } }
void Awake() { if (instance != null && instance != this) { Destroy(gameObject); } if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } /* if (instance != null && instance != this) * { * Destroy(this.gameObject); * return; * } * else * { * instance = this; * } * * DontDestroyOnLoad(this.gameObject);*/ }