Music is playing through scenes, how I stop it when I need to?

Hello Unity dudes,

So i have 1 scene (Main Menu) with my audio source and three more levels with a bunch of scenes. Every level has an Audio source with this script that plays music across scenes.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BGSoundScript : MonoBehaviour {

	// Use this for initialization
	void Start () {

    //Play Global
    private static BGSoundScript instance = null;
    public static BGSoundScript Instance
        get { return instance; }

    void Awake()
        if (instance != null && instance != this)
            instance = this;

    //Play Gobal End

    // Update is called once per frame
    void Update () {

It works like charm. But for example when you finish level 1 and you return to menu, you have 2 audios playing…when you start level 2 more audio source and so on.

So I would like to ask how do I manage this? Any thoughts?

Hi mate, I might not understand what you’re asking, but if you have multiple AudioSources then you could call AudioSource.Stop() on the correct audioSource at the end of the level before you load the menu scene.

Hope this helped :slight_smile:

I will try to make it more clear. I have 1 scene which is my main menu with a song. When you click play you can choose up to 3 levels. Every level has multiple scenes, with different song for each level. When you finish a level you return to the menu and possible you would go for another level. How do I stop my audio source on the last scene which actually is a scene with a video player attached and changes scene when the video ends.