private IEnumerator CoFade(Fadeable f, float time, float start, float end, int fadingPosition, FadeType fadeType, float pow) { if (time == 0) { yield break; } float eTime = 0f; f.fading[fadingPosition] = true; f.FadeLevel = start; while (eTime < time && f.fading[fadingPosition]) { eTime += Time.deltaTime; switch (fadeType) { case FadeType.Lin: f.FadeLevel = Mathf.Lerp(start, end, eTime / time); break; case FadeType.Exp: f.FadeLevel = MathfExtended.SteepErp(start, end, pow, eTime / time); break; case FadeType.Log: f.FadeLevel = MathfExtended.ShallowErp(start, end, pow, eTime / time); break; } yield return(0); } if (f.fading[fadingPosition]) { f.FadeLevel = end; f.fading[fadingPosition] = false; } }
public float Get() { if (!autoDecay) { return(Percent); } float e = 0f; switch (decayCurve) { case FadeType.Lin: e = Mathf.Lerp(0f, 1f, Percent); break; case FadeType.Exp: e = MathfExtended.SteepErp(0f, 1f, power, Percent); break; case FadeType.Log: e = MathfExtended.ShallowErp(0f, 1f, power, Percent); break; } return(e); }