void FixFadeSettings(ref FadeSettings fs)
 {
     if (fs.fadeDuration < 0)
     {
         fs.fadeDuration = 0;
     }
 }
Exemplo n.º 2
0
        public void SetFade(float progress, FadeSettings fadeSettings)
        {
            if (this == null)
            {
                return;               //Had to do this to fix a unity engine bug with editor fade preview.
            }
            //Position Offset:
            Vector2 posOffset = fadeSettings.positionOffset * (progress - 1);

            textA.transform.localPosition = posOffset;
            textB.transform.localPosition = -posOffset;

            //Scale & Scale Offset:
            Vector2 scaleOffset = fadeSettings.scaleOffset;

            if (scaleOffset.x == 0)
            {
                scaleOffset.x += 0.001f;
            }
            if (scaleOffset.y == 0)
            {
                scaleOffset.y += 0.001f;
            }

            Vector3 scaleA = Vector2.Lerp(scaleOffset * fadeSettings.scale, Vector2.one, progress);

            scaleA.z = 1;
            Vector3 scaleB = Vector2.Lerp(new Vector3(1f / scaleOffset.x, 1f / scaleOffset.y, 1) * fadeSettings.scale, Vector2.one, progress);

            scaleB.z = 1;

            textA.transform.localScale = scaleA;
            textB.transform.localScale = scaleB;

            //Alpha:
            UpdateAlpha(progress);
        }