// Update is called once per frame void Update() { if (currentState != gameState.GetMusicState()) { currentState = gameState.GetMusicState(); PlayMusic(currentState); } }
// Use this for initialization void Start() { gameState = GameObject.Find("GameState").GetComponent <GameStateScript>(); gameMusic = GetComponent <AudioSource>(); music = new Dictionary <string, AudioClip>(); music.Add("FlushedTestSong1", Resources.Load("FlushedTestSong1") as AudioClip); music.Add("FlushedTestSong2", Resources.Load("FlushedTestSong2") as AudioClip); music.Add("Siren", Resources.Load("siren") as AudioClip); currentState = gameState.GetMusicState(); PlayMusic(currentState); //Debug.Log(Resources.Load("FlushedTestSong1")); }