Esempio n. 1
0
    static public TweenPosition Begin(GameObject go, float duration, Vector3 From, Vector3 pos, ButtonCallBack CallBack)
    {
        TweenPosition comp = UITweener.Begin <TweenPosition>(go, duration);

        comp.CallBackWhenFinished = CallBack;
        comp.from = From;
        comp.to   = pos;
        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
            CallBack(comp.gameObject);
        }
        return(comp);
    }
Esempio n. 2
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenPosition Begin(GameObject go, float duration, Vector3 pos, bool worldSpace)
    {
        TweenPosition comp = UITweener.Begin <TweenPosition>(go, duration);

        comp.worldSpace = worldSpace;
        comp.from       = comp.value;
        comp.to         = pos;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Esempio n. 3
0
    static public TweenPosition Begin(GameObject go, float duration, Vector3 start, Vector3 end)
    {
        go.transform.localPosition = start;
        TweenPosition comp = UITweener.Begin <TweenPosition>(go, duration);

        comp.from = comp.position;
        comp.to   = end;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Esempio n. 4
0
    void Append()
    {
        GameObject item = invisibleQ.Dequeue();

        lastItem = item;
        item.SetActive(true);
        item.transform.localPosition = nextPosition;
        TweenPosition tween = item.GetComponent <TweenPosition>();

        tween.enabled     = true;
        tween.tweenFactor = (tween.from.y - nextPosition.y) / (tween.from.y - tween.to.y);
        tween.Sample(tween.tweenFactor, false);
        tween.PlayForward();
        visibleQ.Enqueue(item);
    }
Esempio n. 5
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>
    static public TweenPosition Begin(GameObject target, float duration, Vector3 pos, bool worldSpace)
    {
        TweenPosition tweenComp = UITweener.Begin <TweenPosition>(target, duration);

        tweenComp.worldSpace = worldSpace;
        tweenComp.from       = tweenComp.value;
        tweenComp.to         = pos;

        if (duration <= 0f)
        {
            tweenComp.Sample(1f, true);
            tweenComp.enabled = false;
        }
        return(tweenComp);
    }
Esempio n. 6
0
    public static TweenPosition Begin(GameObject go, Vector3 from, Vector3 to, float duration = 1f, float delay = 0f)
    {
        TweenPosition comp = Begin <TweenPosition>(go, duration);

        comp.value    = from;
        comp.from     = from;
        comp.to       = to;
        comp.duration = duration;
        comp.delay    = delay;
        if (duration <= 0)
        {
            comp.Sample(1, true);
            comp.enabled = false;
        }
        return(comp);
    }
Esempio n. 7
0
    static public TweenPosition Begin(GameObject go, float duration, Vector3 pos, EventDelegate finish)
    {
        TweenPosition comp = UITweener.Begin <TweenPosition>(go, duration);

        comp.from       = comp.value;
        comp.to         = pos;
        comp.onFinished = new System.Collections.Generic.List <EventDelegate>()
        {
            finish
        };
        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Esempio n. 8
0
    public static TweenPosition Begin(GameObject go, float duration, Vector3 pos)
    {
        //IL_000b: Unknown result type (might be due to invalid IL or missing references)
        //IL_0010: Unknown result type (might be due to invalid IL or missing references)
        //IL_0016: Unknown result type (might be due to invalid IL or missing references)
        //IL_0017: Unknown result type (might be due to invalid IL or missing references)
        TweenPosition tweenPosition = UITweener.Begin <TweenPosition>(go, duration, true);

        tweenPosition.from = tweenPosition.value;
        tweenPosition.to   = pos;
        if (duration <= 0f)
        {
            tweenPosition.Sample(1f, true);
            tweenPosition.set_enabled(false);
        }
        return(tweenPosition);
    }
Esempio n. 9
0
 public void ResetUIPlayTweenTargetToBegining()
 {
     if (this.NGUIPlayTween != null && this.NGUIPlayTween.tweenTarget != null)
     {
         GameObject    tweenTarget = this.NGUIPlayTween.tweenTarget;
         TweenPosition component   = tweenTarget.GetComponent <TweenPosition>();
         if (component != null)
         {
             component.enabled = false;
             component.ResetToBeginning();
             component.Sample(0f, true);
             component.tweenFactor = 0f;
         }
         TweenAlpha component2 = tweenTarget.GetComponent <TweenAlpha>();
         if (component2 != null)
         {
             component2.ResetToBeginning();
             component2.Sample(0f, true);
             component2.tweenFactor = 0f;
             component2.enabled     = false;
         }
     }
 }
Esempio n. 10
0
    public static TweenPosition MoveTo(bool reset, GameObject go, UITweener.Method method, UITweener.Style style,
                                       float duration, float delay, Vector3 pos)
    {
        if (go == null)
        {
            return(null);
        }

        if (reset)
        {
            //go.RemoveComponent<TweenPosition>();
        }

        TweenPosition comp = UITweenerUtil.Begin <TweenPosition>(go, method, style, duration, delay);

        if (reset)
        {
            comp = ResetTween(comp);
        }
        comp.from     = comp.position;
        comp.to       = pos;
        comp.duration = duration;
        comp.delay    = delay;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        if (!reset)
        {
            comp = ResetTween(comp);
        }
        comp.Play(true);
        return(comp);
    }
Esempio n. 11
0
    void Start()
    {
        ////code for testing
        //Begin();
        //onCreateItem += OnCreateItem;
        //onHandleClick += OnHandleClickTest;
        //onEnd += OnEnd;
        ////----------------

        //create items
        for (int i = 0; i < itemCount; ++i)
        {
            GameObject item = CommonFunction.InstantiateObject(itemPrefab, scrollArea.transform);
            item.SetActive(false);
            invisibleQ.Enqueue(item);
            if (i == preselectedItemIndex)
            {
                preselectedItem = item;
            }

            if (onCreateItem != null)
            {
                onCreateItem(item, i);
            }
        }

        scrollAreaHeight = (int)scrollArea.clipRange.w;
        itemHeight       = invisibleQ.Peek().GetComponent <UIWidget>().height;
        visibleItemCount = Mathf.CeilToInt((float)scrollAreaHeight / itemHeight) + 1;
        if (visibleItemCount > itemCount)
        {
            Debug.LogError("Visible item count: " + visibleItemCount + " item count: " + itemCount +
                           ", enlarge item or shrink scroll area.");
        }

        //add tween to item
        tweeners = new TweenPosition[itemCount];
        for (int i = 0; i < itemCount; ++i)
        {
            GameObject    item  = invisibleQ.Dequeue();
            TweenPosition tween = item.AddComponent <TweenPosition>();
            tween.from.y   = itemHeight * visibleItemCount / 2;
            tween.to.y     = -tween.from.y;
            tween.method   = UITweener.Method.Linear;
            tween.enabled  = false;
            tween.duration = itemDuration;
            tween.AddOnFinished(() => { OnItemTweenFinished(item); });
            tweeners[i] = tween;
            invisibleQ.Enqueue(item);
        }

        //place visible item
        int y = -scrollAreaHeight / 2 + (scrollAreaHeight / 2 - itemHeight / 2) % itemHeight - itemHeight / 2;

        while (true)
        {
            GameObject item = invisibleQ.Dequeue();
            lastItem = item;
            item.SetActive(true);
            item.transform.localPosition = new Vector3(0f, y, 0f);
            TweenPosition tween = item.GetComponent <TweenPosition>();
            tween.tweenFactor = (tween.from.y - y) / (tween.from.y - tween.to.y);
            tween.Sample(tween.tweenFactor, false);
            visibleQ.Enqueue(item);
            if ((y + itemHeight / 2) >= scrollAreaHeight / 2)
            {
                break;
            }
            y += itemHeight;
        }

        initialized = true;
        if (autoBegin)
        {
            Begin();
        }
    }