示例#1
0
        /*
         * =====
         * Private Methods
         * =====
         */

        /*
         *  Starts the next tween in the tweens List
         */
        private void StartNextTween(float delay = 0f)
        {
            //remove any listeners from previous tween
            if (activeTween != null)
            {
                activeTween.OnTweenProgress -= OnTweenProgress;
                activeTween.OnTweenComplete -= OnTweenComplete;
            }

            //grab the next tween step
            NDTweenTimelineStep step = (NDTweenTimelineStep)tweens[currentTween];

            // start the tweem
            if (step.isTo)
            {
                activeTween = NDTween.To(
                    step.target,
                    step.timeInSeconds,
                    step.position,
                    step.scale,
                    step.rotation,
                    step.color,
                    step.colorTarget,
                    step.easing,
                    step.delay + delay,
                    true,
                    true,
                    true,
                    step.isUi
                    );
            }
            else
            {
                activeTween = NDTween.From(
                    step.target,
                    step.timeInSeconds,
                    step.position,
                    step.scale,
                    step.rotation,
                    step.color,
                    step.colorTarget,
                    step.easing,
                    step.delay + delay,
                    true,
                    true,
                    true,
                    step.isUi
                    );
            }

            // listen to tween events for new tween
            activeTween.OnTweenComplete += OnTweenComplete;
            activeTween.OnTweenProgress += OnTweenProgress;

            if (OnTimelineStart != null)
            {
                OnTimelineStart();
            }
        }
示例#2
0
        /*
         *  Staggers the firing of tweens in the provided array by the specified delay
         */
        static public void Stagger(NDTweenWorker[] tweens, float delay)
        {
            NDTweenWorker tween;

            for (int i = 0; i < tweens.Length; i++)
            {
                tween = tweens[i];
                float newDelay = tween.delay + (delay * i);
                if (tween.isTo)
                {
                    NDTween.To(tween.targetGameObject, tween.tweenTimeInSeconds, tween.endPosition, tween.endScale, tween.endRotation, tween.endColor, tween.colorTarget, tween.easingEquation, newDelay, tween.destroyOnComplete, tween.clearCurrentTweens, true, tween.isUI);
                }
                else
                {
                    NDTween.From(tween.targetGameObject, tween.tweenTimeInSeconds, tween.startPosition, tween.startScale, tween.startRotation, tween.startColor, tween.colorTarget, tween.easingEquation, newDelay, tween.destroyOnComplete, tween.clearCurrentTweens, true, tween.isUI);
                }
            }
        }
示例#3
0
        /*
         *  Fire the tween again, will reset object to it's start position before doing the same motion
         */
        public NDTweenWorker Retrigger(float extraDelay = 0f)
        {
            // check for any other NDTweenWorker components
            NDTweenWorker[] workers             = targetGameObject.GetComponents <NDTweenWorker>();
            bool            needsToBeAddedAgain = true;

            // loop through to see if this one exists on targetGameObject
            for (int i = 0; i < workers.Length; i++)
            {
                if (workers[i] == this)
                {
                    needsToBeAddedAgain = false;
                }
            }

            // reset targetGameObject properties
            SetTargetPosition(isTo ? startPosition : endPosition);
            SetTargetScale(isTo ? startScale : endScale);
            SetTargetRotation(isTo ? startRotation : endRotation);
            if (isUI)
            {
                targetGameObject.GetComponent <CanvasRenderer>().SetAlpha(isTo ? startAlpha : endAlpha);
            }
            else if (hasRenderer)
            {
                targetGameObject.GetComponent <Renderer>().material.SetColor(colorTarget, isTo ? startColor : endColor);
            }

            //if not present, fire through NDTween as initially fired
            if (needsToBeAddedAgain)
            {
                if (isUI)
                {
                    if (isTo)
                    {
                        return(NDUITween.To(targetGameObject, tweenTimeInSeconds, endPosition, endScale, endRotation, endAlpha, easingEquation, delay, destroyOnComplete, clearCurrentTweens));
                    }
                    else
                    {
                        return(NDUITween.From(targetGameObject, tweenTimeInSeconds, startPosition, startScale, startRotation, startAlpha, easingEquation, delay, destroyOnComplete, clearCurrentTweens));
                    }
                }
                else
                {
                    if (isTo)
                    {
                        return(NDTween.To(targetGameObject, tweenTimeInSeconds, endPosition, endScale, endRotation, endColor, colorTarget, easingEquation, delay, destroyOnComplete, clearCurrentTweens));
                    }
                    else
                    {
                        return(NDTween.From(targetGameObject, tweenTimeInSeconds, startPosition, startScale, startRotation, startColor, colorTarget, easingEquation, delay, destroyOnComplete, clearCurrentTweens));
                    }
                }
            }
            else
            {
                //otherwise call StartTween
                StartTween();
                return(this);
            }
        }
示例#4
0
 static public NDTweenWorker UITo(GameObject target, float timeInSeconds, Vector3 position, Func <float, float> easing = null, float delay = 0f, bool destroyOnComplete = true, bool clearCurrentTweens = true, bool autoPlay = true)
 {
     return(NDTween.To(target, timeInSeconds, position));
 }
示例#5
0
 static public NDTweenWorker To(GameObject target, float timeInSeconds, Vector3 position, Vector3 scale, Vector3 rotation, Color color, string colorTarget, NDTweenOptions options)
 {
     return(NDTween.To(target, timeInSeconds, position, scale, rotation, color, colorTarget, options.easing, options.delay, options.destroyOnComplete, options.clearCurrentTweens, options.autoPlay, options.isUI));
 }
示例#6
0
 static public NDTweenWorker To(GameObject target, float timeInSeconds, Vector3 position, Vector3 scale, Vector3 rotation, Color color, Func <float, float> easing = null, float delay = 0f, bool destroyOnComplete = true, bool clearCurrentTweens = true, bool autoPlay = true, bool isUI = false)
 {
     return(NDTween.To(target, timeInSeconds, position, scale, rotation, color, "_Color", easing, delay, destroyOnComplete, clearCurrentTweens, autoPlay, isUI));
 }
示例#7
0
 static public NDTweenWorker ColorTo(GameObject target, float timeInSeconds, Color color, string colorTarget, NDTweenOptions options)
 {
     return(NDTween.To(target, timeInSeconds, target.transform.localPosition, target.transform.localScale, target.transform.localRotation.eulerAngles, color, colorTarget, options.easing, options.delay, options.destroyOnComplete, options.clearCurrentTweens, options.autoPlay, options.isUI));
 }
示例#8
0
 static public NDTweenWorker ColorTo(GameObject target, float timeInSeconds, Color color, string colorTarget, Func <float, float> easing = null, float delay = 0f, bool destroyOnComplete = true, bool clearCurrentTweens = true, bool autoPlay = true, bool isUI = false)
 {
     return(NDTween.To(target, timeInSeconds, target.transform.localPosition, target.transform.localScale, target.transform.localRotation.eulerAngles, color, colorTarget, easing, delay, destroyOnComplete, clearCurrentTweens, autoPlay, isUI));
 }
示例#9
0
 static public NDTweenWorker RotateTo(GameObject target, float timeInSeconds, Vector3 rotation, NDTweenOptions options)
 {
     return(NDTween.To(target, timeInSeconds, target.transform.localPosition, target.transform.localScale, rotation, NDTween.GetMaterialColor(target, "_Color"), "_Color", options.easing, options.delay, options.destroyOnComplete, options.clearCurrentTweens, options.autoPlay, options.isUI));
 }
示例#10
0
 static public NDTweenWorker RotateTo(GameObject target, float timeInSeconds, Vector3 rotation, Func <float, float> easing = null, float delay = 0f, bool destroyOnComplete = true, bool clearCurrentTweens = true, bool autoPlay = true, bool isUI = false)
 {
     return(NDTween.To(target, timeInSeconds, target.transform.localPosition, target.transform.localScale, rotation, NDTween.GetMaterialColor(target, "_Color"), "_Color", easing, delay, destroyOnComplete, clearCurrentTweens, autoPlay, isUI));
 }