コード例 #1
0
    // Update our sfx array and remove any sound effects that are done playing.
    void Update()
    {
        // Iterate through our sound effects and see if they are done yet... Then remove them.
        // Don't do this if the sfxstate is paused since the sfx won't be playing.
        if (sfxState != SoundPlayerState.Paused)
        {
            for (int i = sfxSources.Count - 1; i >= 0; i--)
            {
                AudioSourceManager sfx = (AudioSourceManager)sfxSources[i];
                if (sfx.source != null && !sfx.source.isPlaying)
                {
                    sfxSources.Remove(sfx);
                    sfx.Destroy();
                }
            }
        }

        // If the bgm is not on loop and finishes, update bgmState to match
        if (bgmState == SoundPlayerState.Playing && !bgmSource.isPlaying)
        {
            bgmState = SoundPlayerState.Stopped;
        }
    }