private void Awake() { if (instance != null) { Destroy(this.gameObject); } else { instance = this; DontDestroyOnLoad(gameObject); } }
private void Start() { if (instance == null) { instance = this; DontDestroyOnLoad(this.gameObject); SceneManager.activeSceneChanged += changeBackgroundAudio; audio = GetComponent <AudioSource>(); // audio.clip=menuBackgroundAudio; audio.Play(); } else { Destroy(this.gameObject); } }