/// <summary> /// Fades all match audio out. /// </summary> /// <param name="duration">The duration of the fade in seconds.</param> /// <returns>The awaitable task.</returns> public async UniTask FadeOutAllAsync(float duration) { var goalHorn = _goalHorn.FadeOutAsync(duration, _cancellationTokenSource.Token); var goalCrowd = _goalCrowd.FadeOutAsync(duration, _cancellationTokenSource.Token); var loop = _loop.FadeOutAsync(duration, _cancellationTokenSource.Token); await UniTask.WhenAll(goalHorn, goalCrowd, loop); }
public void FadeOutMusic(MonoBehaviour script, float duration) { script.StartCoroutine(musicSource.FadeOutAsync(duration)); }