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

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

        comp.from = comp.position;
        comp.to   = pos;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenAlpha Begin(GameObject go, float duration, float alpha)
    {
        TweenAlpha comp = NGUITweener.Begin <TweenAlpha>(go, duration);

        comp.from = comp.alpha;
        comp.to   = alpha;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenOrthoSize Begin(GameObject go, float duration, float to)
    {
        TweenOrthoSize comp = NGUITweener.Begin <TweenOrthoSize>(go, duration);

        comp.from = comp.orthoSize;
        comp.to   = to;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenTransform Begin(GameObject go, float duration, Transform from, Transform to)
    {
        TweenTransform comp = NGUITweener.Begin <TweenTransform>(go, duration);

        comp.from = from;
        comp.to   = to;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenVolume Begin(GameObject go, float duration, float targetVolume)
    {
        TweenVolume comp = NGUITweener.Begin <TweenVolume>(go, duration);

        comp.from = comp.volume;
        comp.to   = targetVolume;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenScale Begin(GameObject go, float duration, Vector3 scale)
    {
        TweenScale comp = NGUITweener.Begin <TweenScale>(go, duration);

        comp.from = comp.scale;
        comp.to   = scale;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenRotation Begin(GameObject go, float duration, Quaternion rot)
    {
        TweenRotation comp = NGUITweener.Begin <TweenRotation>(go, duration);

        comp.from = comp.rotation.eulerAngles;
        comp.to   = rot.eulerAngles;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenColor Begin(GameObject go, float duration, Color color)
    {
        TweenColor comp = NGUITweener.Begin <TweenColor>(go, duration);

        comp.from = comp.color;
        comp.to   = color;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 9
0
    void Update()
    {
        if (disableWhenFinished != DisableCondition.DoNotDisable && mTweens != null)
        {
            bool isFinished      = true;
            bool properDirection = true;

            for (int i = 0, imax = mTweens.Length; i < imax; ++i)
            {
                NGUITweener tw = mTweens[i];
                if (tw.tweenGroup != tweenGroup)
                {
                    continue;
                }

                if (tw.enabled)
                {
                    isFinished = false;
                    break;
                }
                else if ((int)tw.direction != (int)disableWhenFinished)
                {
                    properDirection = false;
                }
            }

            if (isFinished)
            {
                if (properDirection)
                {
                    NGUITools.SetActive(tweenTarget, false);
                }
                mTweens = null;
            }
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// Activate the tweeners.
    /// </summary>

    public void Play(bool forward)
    {
        GameObject go = (tweenTarget == null) ? gameObject : tweenTarget;

        if (!NGUITools.GetActive(go))
        {
            // If the object is disabled, don't do anything
            if (ifDisabledOnPlay != EnableCondition.EnableThenPlay)
            {
                return;
            }

            // Enable the game object before tweening it
            NGUITools.SetActive(go, true);
        }

        // Gather the tweening components
        mTweens = includeChildren ? go.GetComponentsInChildren <NGUITweener>() : go.GetComponents <NGUITweener>();

        if (mTweens.Length == 0)
        {
            // No tweeners found -- should we disable the object?
            if (disableWhenFinished != DisableCondition.DoNotDisable)
            {
                NGUITools.SetActive(tweenTarget, false);
            }
        }
        else
        {
            bool activated = false;
            if (playDirection == Direction.Reverse)
            {
                forward = !forward;
            }

            // Run through all located tween components
            for (int i = 0, imax = mTweens.Length; i < imax; ++i)
            {
                NGUITweener tw = mTweens[i];

                // If the tweener's group matches, we can work with it
                if (tw.tweenGroup == tweenGroup)
                {
                    // Ensure that the game objects are enabled
                    if (!activated && !NGUITools.GetActive(go))
                    {
                        activated = true;
                        NGUITools.SetActive(go, true);
                    }

                    // Toggle or activate the tween component
                    if (playDirection == Direction.Toggle)
                    {
                        tw.Toggle();
                    }
                    else
                    {
                        tw.Play(forward);
                    }
                    if (resetOnPlay)
                    {
                        tw.Reset();
                    }

                    // Set the delegate
                    tw.onFinished = onFinished;

                    // Copy the event receiver
                    if (eventReceiver != null && !string.IsNullOrEmpty(callWhenFinished))
                    {
                        tw.eventReceiver    = eventReceiver;
                        tw.callWhenFinished = callWhenFinished;
                    }
                }
            }
        }
    }