Question by
An00bi · Jul 11, 2017 at 06:55 AM ·
unity 5audioaudiosourceaudioclip
Audio Source stop playing even with "DontDestroyOnLoad"
This is my simple code attached to my GameObject with the Audio Source (Play Awake ON):
public class Music : MonoBehaviour {
void Awake() {
GameObject[] objs = GameObject.FindGameObjectsWithTag("GameMusic");
if(objs.Length > 1) {
Destroy(this.gameObject);
}
DontDestroyOnLoad(this.gameObject);
}
}
I've red a lot of threads (and tried different solutions) where the crucial point to make this script work is "DontDestroyOnLoad", but as soon as I load another scene I still can see my object with the music/script but it stop playing.
Comment