private IEnumerator ChangeVolumeTo(float target) { return(GameUtils.AnimateValue( () => _audioSource.volume, value => _audioSource.volume = value, target, VolumeChangeRate)); }
private static IEnumerator AnimateAlpha(Graphic gr, float targetValue, float alphaRate) { return(GameUtils.AnimateValue( () => gr.color.a, a => gr.color = GameUtils.SetColorAlpha(gr.color, a), targetValue, alphaRate)); }
private IEnumerator HideTip(Text tip) { yield return(StartCoroutine(GameUtils.AnimateValue( () => tip.color.a, v => tip.color = GameUtils.SetColorAlpha(tip.color, v), 0f, TipAlphaRate))); tip.gameObject.SetActive(false); }
private IEnumerator ShowTip(Text tip) { yield return(HideAllTips()); tip.gameObject.SetActive(true); tip.color = GameUtils.SetColorAlpha(tip.color, 0f); yield return(StartCoroutine(GameUtils.AnimateValue( () => tip.color.a, v => tip.color = GameUtils.SetColorAlpha(tip.color, v), TipAlpha, TipAlphaRate))); }
private IEnumerator SetLightState(Light lightComponent, float initIntensity, bool state) { const float tolerance = 0.01f; if (lightComponent.gameObject.activeSelf == state && Math.Abs(lightComponent.intensity - initIntensity) < tolerance) { yield break; } float target = state ? initIntensity : 0f; lightComponent.gameObject.SetActive(true); yield return(StartCoroutine(GameUtils.AnimateValue( () => lightComponent.intensity, v => lightComponent.intensity = v, target, 0.04f))); lightComponent.gameObject.SetActive(state); }