Scene switch and continuous sound

When you move to the next scene,
The previous scene’s sound leads to come out,
What should I do?

When loading a new level all objects in the scene are destroyed, then the objects in the new level are loaded. In order to preserve an object during level loading call DontDestroyOnLoad on it. If the object is a component or game object then its entire transform hierarchy will not be destroyed either.

  1. Add an empty gameobject (say MenuSound) to the scene.

  2. Add an audio clip to the object.

  3. Add following code to any object which is present in the same scene.

    void Awake()
    {
    DontDestroyOnLoad(GameObject.Find(“MenuSound”).gameObject);
    }

This code will not destroy the object while switching the scene. And audio will be played continiously.