Example #1
0
    public void PlayBackgroundNoise(BackgroundNoise type)
    {
        if (type == currentType)
        {
            return;
        }

        ForcePlayBackgroundNoise(type);
    }
Example #2
0
    private AudioSource GetAudioSource(BackgroundNoise type)
    {
        switch (type)
        {
        case BackgroundNoise.Basement:
            return(basementSource);

        case BackgroundNoise.Outdoors:
            return(outdoorSource);

        default:
            Debug.LogError("Unrecognized background noise type: " + type);
            return(null);
        }
    }
Example #3
0
    private void ForcePlayBackgroundNoise(BackgroundNoise type)
    {
        currentType = type;

        previousSource = currentSource;
        currentSource  = GetAudioSource(currentType);

        if (previousSource != null)
        {
            StartCoroutine(FadeAudioSource.StartFade(previousSource, crossFadeDurationSec, 0));
        }

        if (currentSource != null)
        {
            StartCoroutine(FadeAudioSource.StartFade(currentSource, crossFadeDurationSec, volume));
        }
    }