protected override void OnTrigger() { IEnumerator routine = null; switch (type) { case Type.Color: routine = Routines.Lerp(material.color, color, duration, (Color val) => { material.color = val; }, Color.Lerp); break; case Type.SetFloat: routine = Routines.Lerp(material.GetFloat(propertyName), floatValue, duration, (float val) => { material.SetFloat(propertyName, val); }, Routines.Lerp); break; case Type.SetInteger: routine = Routines.Lerp(material.GetInt(propertyName), integerValue, duration, (float val) => { material.SetInt(propertyName, Mathf.CeilToInt(val)); }, Routines.Lerp); break; case Type.SetTexture: routine = Routines.Call(() => { material.SetTexture(propertyName, texture); }, duration); break; case Type.Lerp: routine = Routines.Lerp((float t) => { material.Lerp(material, material2, t); }, duration); break; default: break; } this.StartCoroutine(routine, "Interpolate"); }
public void FadeColor(Color color, float duration, bool ignoreTimeScale) { if (debug) { Trace.Script("Fading to " + color, this); } previousColor = currentColor; currentColor = color; //image.CrossFadeColor(color, duration, ignoreTimeScale, useAlpha); this.StartCoroutine(Routines.Lerp(image.color, color, duration, (Color val) => { image.color = val; }, Color.Lerp), "Fade Color"); }
//--------------------------------------------------------------------------------------------/ // Methods //--------------------------------------------------------------------------------------------/ public void Fade(float alpha, float duration, bool ignoreTimeScale) { if (debug) { Trace.Script("Fading to " + alpha, this); } previousAlpha = currentAlpha; currentAlpha = alpha; //image.CrossFadeAlpha(alpha, duration, ignoreTimeScale); this.StartCoroutine(Routines.Lerp(image.color.a, alpha, duration, (float val) => { image.color = image.color.ToAlpha(val); }, Routines.Lerp), "Fade"); }