예제 #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
        /*
         * =====
         * Private Methods
         * =====
         */

        /**
         *  Creates an NDTweenWorker component on the target game object
         */
        static private NDTweenWorker CreateTweenWorker(bool isTo, GameObject target, Vector3 position, Vector3 scale, Vector3 rotation, Color color, string colorTarget, float timeInSeconds, Func <float, float> easing = null, float delay = 0f, bool destroyOnComplete = true, bool clearCurrentTweens = false, bool autoPlay = true, bool isUI = false, bool isGlobal = false)
        {
            //remove any previous tweens if needed
            if (clearCurrentTweens)
            {
                NDTween.RemoveAllTweens(target);
            }

            //create the component and add to the target game object
            NDTweenWorker tweenWorker = target.AddComponent <NDTweenWorker>();

            tweenWorker.targetGameObject = target;

            //set tween properties
            tweenWorker.startPosition = isTo ? isGlobal ? target.transform.position : target.transform.localPosition : position;
            tweenWorker.endPosition   = isTo ? position : isGlobal ? target.transform.position : target.transform.localPosition;

            tweenWorker.startScale = isTo ? target.transform.localScale : scale;
            tweenWorker.endScale   = isTo ? scale : target.transform.localScale;

            tweenWorker.startRotation = isTo ? target.transform.localRotation.eulerAngles : rotation;
            tweenWorker.endRotation   = isTo ? rotation : target.transform.localRotation.eulerAngles;

            tweenWorker.startColor = isTo ? NDTween.GetMaterialColor(target, colorTarget) : color;
            tweenWorker.endColor   = isTo ? color : NDTween.GetMaterialColor(target, colorTarget);

            tweenWorker.colorTarget = colorTarget;

            tweenWorker.tweenTimeInSeconds = timeInSeconds;
            tweenWorker.delay = delay;

            tweenWorker.isTo = isTo;

            tweenWorker.isUI = isUI;

            tweenWorker.easingEquation = NDTween.GetEasingEquation(easing);

            tweenWorker.destroyOnComplete = destroyOnComplete;

            //start it
            if (autoPlay)
            {
                tweenWorker.StartTween();
            }

            //return reference
            return(tweenWorker);
        }
예제 #3
0
        static private NDTweenWorker CreateTweenWorker(bool isTo, GameObject target, Vector3 position, Vector3 scale, Vector3 rotation, float alpha, float timeInSeconds, Func <float, float> easing = null, float delay = 0f, bool destroyOnComplete = true, bool clearCurrentTweens = false, bool autoPlay = true)
        {
            //remove any previous tweens if needed
            if (clearCurrentTweens)
            {
                NDTween.RemoveAllTweens(target);
            }

            //create the component and add to the target game object
            NDTweenWorker tweenWorker = target.AddComponent <NDTweenWorker>();

            tweenWorker.targetGameObject = target;

            //set tween properties
            tweenWorker.startPosition = isTo ? target.GetComponent <RectTransform>().localPosition : position;
            tweenWorker.endPosition   = isTo ? position : target.GetComponent <RectTransform>().localPosition;

            tweenWorker.startScale = isTo ? target.GetComponent <RectTransform>().localScale : scale;
            tweenWorker.endScale   = isTo ? scale : target.GetComponent <RectTransform>().localScale;

            tweenWorker.startRotation = isTo ? target.GetComponent <RectTransform>().localRotation.eulerAngles : rotation;
            tweenWorker.endRotation   = isTo ? rotation : target.GetComponent <RectTransform>().localRotation.eulerAngles;

            tweenWorker.startAlpha = isTo ? target.GetComponent <CanvasRenderer>().GetAlpha() : alpha;
            tweenWorker.endAlpha   = isTo ? alpha : target.GetComponent <CanvasRenderer>().GetAlpha();

            tweenWorker.tweenTimeInSeconds = timeInSeconds;
            tweenWorker.delay = delay;

            tweenWorker.isTo = isTo;

            tweenWorker.isUI = true;

            tweenWorker.easingEquation = NDTween.GetEasingEquation(easing);

            tweenWorker.destroyOnComplete = destroyOnComplete;

            //start it
            if (autoPlay)
            {
                tweenWorker.StartTween();
            }

            //return reference
            return(tweenWorker);
        }