I have some problem. I wanted to make my audio clip play always between the scenes. So i created a Gameobject, atached a audio sorce, and script
public bool Always;
public GameObject music;
void Awake ()
{
if (Always)
{
DontDestroyOnLoad(music.transform.gameObject);
}
}
It works good, but…
The game starts from first scene, then if i move to another scene music is playing. But when i go back to first scene , my gameobject is still not destroyed and music is playing.But it appears a new the same gameobject with this audiosource and there are two audioclips playing at the same moment.
Every time when i am going back to first scene new gameobject with audiosource appears and starts playing.
How can i avoid this?
Thanks