Example #1
0
        private IEnumerator FadeCoroutine(float fromAlpha, float toAlpha, OnFadeCompleted callback, float fadeSpeed)
        {
            Color temp;

            float progress = 0f;

            while (progress < 1f)
            {
                LerpImageAlphaColor(fromAlpha, toAlpha, progress);

                yield return(new WaitForEndOfFrame());

                progress += (Time.unscaledDeltaTime * fadeSpeed) / 100f;
            }
            // Ensures that the image is completed faded at the end.
            LerpImageAlphaColor(fromAlpha, toAlpha, 1);

            callback?.Invoke();

            yield return(null);

            #region Local_Function

            void LerpImageAlphaColor(float a, float b, float t)
            {
                temp              = imageToFade.color;
                temp.a            = Mathf.Lerp(a, b, t);
                imageToFade.color = temp;
            }

            #endregion
        }
Example #2
0
        internal void FadeOutImage(OnFadeCompleted callback, float fadeSpeed)
        {
            StopFadeCoroutineIfExists();

            fadeCoroutine = StartCoroutine(FadeCoroutine(minMaxAlpha.Max, minMaxAlpha.Min, callback, fadeSpeed));
        }
Example #3
0
 internal void FadeInImage(OnFadeCompleted callback = null)
 {
     FadeInImage(callback, defaultFadeSpeed);
 }
Example #4
0
 internal void FadeOutImage(OnFadeCompleted callback)
 {
     FadeOutImage(callback, defaultFadeSpeed);
 }
Example #5
0
 public static void FireOnFadeCompleted(String fadedObjectName)
 {
     OnFadeCompleted?.Invoke(fadedObjectName);
 }