Exemplo n.º 1
0
    private void playBGMAuto(string musicName, bool loop)
    {
        bool playFlag = false;

        for (int i = 0; i < bgmSources.Length; i++)
        {
            if (bgmSources[i].isPlaying && bgmSources[i].clip != null)
            {
                coroutines[0] = StartCoroutine(fadeAudio(bgmSources[i], false));
            }

            if (!bgmSources[i].isPlaying && bgmSources[i].clip == null && !playFlag)
            {
                playFlag = true;

                bgmSources[i].clip = audioLibrary.GetBGMClips(musicName);
                bgmSources[i].loop = loop;
                bgmSources[i].volume = 0;
                bgmSources[i].Play();

                activeChannel = i;

                coroutines[1] = StartCoroutine(fadeAudio(bgmSources[i], true));
            }
        }
    }