Ejemplo n.º 1
0
    void Update()
    {
        bool done = false;

        mCurrentTime += Time.deltaTime;
        if (mCurrentTime >= mOwner.TotalTime)
        {
            mCurrentTime = mOwner.TotalTime;
            done         = true;
        }

        float t = mCurrentTime / mOwner.TotalTime;

        switch (mOwner.AnimationType)
        {
        case PopupMessage.Animation.FlyUp:
            mRectTransform.anchoredPosition = mInitialPosition + mOwner.DirectionAndDistance * t;
            break;

        case PopupMessage.Animation.ZoomIn: {
            float scale = Easing.EaseOutBack(t);
            mRectTransform.localScale = new Vector3(scale, scale, scale);
            break;
        }
        }

        if (mCurrentTime > mOwner.TimeBeforeFade)
        {
            float coeff = 1.0f - (mCurrentTime - mOwner.TimeBeforeFade) / (mOwner.TotalTime - mOwner.TimeBeforeFade);
            Text.color = new Color(mColor.r, mColor.g, mColor.b, mColor.a * coeff);
        }

        if (done)
        {
            mOwner.AddInactiveVisual(this);
        }
    }