Esempio n. 1
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenScrollBarSize Begin(UIScrollBar bar, float duration, float to)
    {
        TweenScrollBarSize comp = UITweener.Begin <TweenScrollBarSize>(bar.gameObject, duration);

        comp.from       = comp.value;
        comp.to         = to;
        comp.mScrollBar = bar;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
    private void PlayAnimation(bool istop)
    {
        if (animLock)
        {
            return;
        }
        animLock = true;
        islock   = true;
        Vector3       rpos = mRoot.localPosition;
        Vector3       pos  = istop ? new Vector3(rpos.x, rpos.y - Height / 2, rpos.z) : new Vector3(rpos.x, rpos.y + Height / 2, rpos.z);
        TweenPosition tp   = TweenPosition.Begin(mRoot.gameObject, 0.3f, pos);

        tp.method = UITweener.Method.EaseInOut;
        tp.AddOnFinished(() =>
        {
            DestroyImmediate(tp);
            if (this != null)
            {
                TweenPosition temp = TweenPosition.Begin(mRoot.gameObject, 0.3f, rpos);
                temp.AddOnFinished(() =>
                {
                    animLock = false;
                    islock   = false;
                    DestroyImmediate(temp);
                });
                temp.PlayForward();
            }
            else
            {
                animLock = false;
                islock   = false;
            }
        });
        tp.PlayForward();

        if (MainBar != null)
        {
            float ori             = MainBar.barSize;
            float size            = ori / 2;
            TweenScrollBarSize tb = TweenScrollBarSize.Begin(MainBar, 0.6f, 0);
            tb.method = UITweener.Method.EaseInOut;
            tb.AddOnFinished(() =>
            {
                DestroyImmediate(tb);
                TweenScrollBarSize tb2 = TweenScrollBarSize.Begin(MainBar, 0.2f, ori);
                tb2.PlayForward();
                tb2.AddOnFinished(() =>
                {
                    DestroyImmediate(tb2);
                });
            });
            tb.PlayForward();
        }

        if (CorBar != null)
        {
            float ori             = CorBar.barSize;
            float size            = ori / 2;
            TweenScrollBarSize tb = TweenScrollBarSize.Begin(CorBar, 0.6f, 0);
            tb.method = UITweener.Method.EaseInOut;
            tb.AddOnFinished(() =>
            {
                DestroyImmediate(tb);
                TweenScrollBarSize tb2 = TweenScrollBarSize.Begin(CorBar, 0.2f, ori);
                tb2.PlayForward();
                tb2.AddOnFinished(() =>
                {
                    DestroyImmediate(tb2);
                });
            });
            tb.PlayForward();
        }
    }