Example #1
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);
        }
Example #2
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);
        }