public static IEnumerator Fade(this CanvasGroup group, float to, float duration) { if (!group.gameObject.activeInHierarchy) { yield break; } if (to == 0) { group.interactable = false; } if (group.alpha == to) { yield break; } yield return(LerpUtility.Lerp(group.alpha, to, duration, t => group.alpha = t, OnComplete)); void OnComplete() { if (to == 1) { group.interactable = true; } } }
private void SetVolumeAll(List <AudioTrack.AudioPlayer> audioPlayers, float lerpRatio) { foreach (AudioTrack.AudioPlayer player in audioPlayers) { float max = player.Volume.Max; float min = player.Volume.Min; player.Audio.volume = Mathf.Clamp01(LerpUtility.Lerp(min, max, lerpRatio)); } }