private void Update() { if (SceneManager.GetActiveScene().buildIndex == 10 || SceneManager.GetActiveScene().buildIndex == 2) { manager = null; Destroy(this.gameObject); } }
void Awake() { if (manager == null) { manager = this; } else if (manager != this) { Destroy(this.gameObject); } DontDestroyOnLoad(this.gameObject); }