Beispiel #1
0
    public static IEnumerator CubicSlideOutY(RectTransform rt, float targetPosition, float animationTime)
    {
        float elapsedTime   = 0;
        float startPosition = rt.anchoredPosition.y;

        while (elapsedTime < animationTime)
        {
            rt.anchoredPosition = new Vector2(
                rt.anchoredPosition.x,
                PennerAnimation.CubicEaseIn(elapsedTime, startPosition, targetPosition - startPosition, animationTime)
                );
            elapsedTime += Time.deltaTime;
            yield return(0);
        }
        rt.anchoredPosition = new Vector2(
            rt.anchoredPosition.x,
            targetPosition
            );
    }
Beispiel #2
0
    public static IEnumerator CubicFade(Image target, float start, float end, float animationTime)
    {
        float elapsedTime = 0;
        Color c           = Color.white;

        while (elapsedTime < animationTime)
        {
            c.a = PennerAnimation.CubicEaseIn(
                elapsedTime,
                start,
                end - start,
                animationTime
                );
            target.color = c;
            elapsedTime += Time.deltaTime;
            yield return(0);
        }
        c.a          = end;
        target.color = c;
    }