How to keep audio from one scene to another in Unity

Asked

Viewed 412 times

3

I’m starting at Unity and would like to know if it is possible to make the audio of one scene be played in another, and this audio will be played in the other scene, starting from the moment it stopped in the previous scene. If you know, I ask you to answer them properly, please.

2 answers

2

Just create a gameObject, put to play the audio on it and create a script with:

void Awake()
{
    DontDestroyOnLoad(gameObject);
}
  • "creates a script..." creates the script where? " just create a gameobject.." anyone? Or it can be a empty? Your answer may be better. Please edit it to add the details. If possible, add small images with the essential parts of the screen where this is done, so that it is really useful to AP (Author of the Question) and other future readers. If you do, you get my +1.

0

First, create a script, in my example Soundcontroller.

Inside the created script put the code

public class soundController : MonoBehaviour {


void Awake()
{
    DontDestroyOnLoad(this.gameObject);
}

After this drag the script to your sound Object. It will work perfectly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.