protected override void OnTrigger()
        {
            IEnumerator routine = null;

            switch (type)
            {
            case Type.Color:
                routine = StratusRoutines.Lerp(material.color, color, duration, (Color val) => { material.color = val; }, Color.Lerp);
                break;

            case Type.SetFloat:
                routine = StratusRoutines.Lerp(material.GetFloat(propertyName), floatValue, duration, (float val) => { material.SetFloat(propertyName, val); }, StratusRoutines.Lerp);
                break;

            case Type.SetInteger:
                routine = StratusRoutines.Lerp(material.GetInt(propertyName), integerValue, duration, (float val) => { material.SetInt(propertyName, Mathf.CeilToInt(val)); }, StratusRoutines.Lerp);
                break;

            case Type.SetTexture:
                routine = StratusRoutines.Call(() => { material.SetTexture(propertyName, texture); }, duration);
                break;

            case Type.Lerp:
                routine = StratusRoutines.Lerp((float t) => { material.Lerp(material, material2, t); }, duration);
                break;

            default:
                break;
            }

            this.StartCoroutine(routine, "Interpolate");
        }
Example #2
0
        public static IEnumerator ComposeCrossFade(this CanvasGroup canvasGroup,
                                                   float alpha,
                                                   bool interactable,
                                                   bool blocksRaycasts,
                                                   float duration,
                                                   Action onFinished = null)
        {
            float initialAlpha = canvasGroup.alpha;

            if (duration > 0.0f)
            {
                yield return(StratusRoutines.Lerp((t) =>
                {
                    canvasGroup.alpha = initialAlpha.LerpTo(alpha, t);
                }, duration));
            }
            else
            {
                canvasGroup.alpha = alpha;
            }

            canvasGroup.blocksRaycasts = blocksRaycasts;
            canvasGroup.interactable   = interactable;

            onFinished?.Invoke();
        }
Example #3
0
 public void FadeColor(Color color, float duration, bool ignoreTimeScale)
 {
     if (debug)
     {
         StratusDebug.Log("Fading to " + color, this);
     }
     previousColor = currentColor;
     currentColor  = color;
     //image.CrossFadeColor(color, duration, ignoreTimeScale, useAlpha);
     this.StartCoroutine(StratusRoutines.Lerp(image.color, color, duration, (Color val) => { image.color = val; }, Color.Lerp), "Fade Color");
 }
Example #4
0
 //--------------------------------------------------------------------------------------------/
 // Methods
 //--------------------------------------------------------------------------------------------/
 public void Fade(float alpha, float duration, bool ignoreTimeScale)
 {
     if (debug)
     {
         StratusDebug.Log("Fading to " + alpha, this);
     }
     previousAlpha = currentAlpha;
     currentAlpha  = alpha;
     //image.CrossFadeAlpha(alpha, duration, ignoreTimeScale);
     this.StartCoroutine(StratusRoutines.Lerp(image.color.a, alpha, duration, (float val) => { image.color = image.color.ScaleAlpha(val); }, StratusRoutines.Lerp), "Fade");
 }
Example #5
0
        public void UpdateProgress(float value, float duration, Action onFinished)
        {
            IEnumerator routine = StratusRoutines.Lerp(progress, value, duration, SetProgress, StratusRoutines.Lerp, onFinished);

            progressRoutine = StartCoroutine(routine);
        }