Ejemplo n.º 1
0
    public static IEnumerator ElasticGrowth(Transform t, float randomOffsetMin, float randomOffsetMax, float animationTime)
    {
        yield return(new WaitForSeconds(randomOffsetMin + Random.value * randomOffsetMax));

        float elapsedTime = 0;

        while (elapsedTime < animationTime)
        {
            float s = PennerAnimation.BounceEaseOut(elapsedTime, 0, 1, animationTime);
            t.localScale = Vector3.one * s;
            elapsedTime += Time.deltaTime;
            yield return(0);
        }
        t.localScale = Vector3.one;
    }
Ejemplo n.º 2
0
    public static IEnumerator FallRectTransform(RectTransform rt, float randomOffsetMin, float randomOffsetMax, float animationTime, Vector3 to)
    {
        float   elapsedTime = 0;
        Vector3 from        = to + Vector3.up * Screen.height * 2;

        rt.anchoredPosition = from;
        while (elapsedTime < animationTime)
        {
            float t = PennerAnimation.BounceEaseOut(elapsedTime, 0, 1, animationTime);
            rt.anchoredPosition = Vector3.Lerp(from, to, t);
            elapsedTime        += Time.deltaTime;
            yield return(0);
        }

        rt.anchoredPosition = to;
    }