Multi-scene songs in Unity?

0

You see, I want to make a background music in Unity but I want it to continue even so change the scene, you know if you can, and if so, how?

    
asked by DSRaptor DEV 06.11.2018 в 02:59
source

1 answer

1

Yes it is possible, the idea is that in your first scene you create the player object and add the following in your main script:

private static bool created = false;

void Awake()
{
    if (!created)
    {
        DontDestroyOnLoad(this.gameObject);
        created = true;
        Debug.Log("Awake: " + this.gameObject);
    }
}

This will allow your player to be always alive, therefore the player will continue between scenes ...

    
answered by 06.11.2018 / 19:57
source