Example #1
0
        /// <summary>
        /// LocalPostion
        /// </summary>
        /// <param name="rTweeningAction"></param>
        /// <param name="rGameObject"></param>
        public static void SetLocalPostion_Behaviour(TweeningAction rTweeningAction, GameObject rGameObject)
        {
            var tras = rGameObject.GetComponent <Transform>();

            tras.localPosition      = rTweeningAction.StartV3;
            rTweeningAction.Tweener = DOTween.To(() => tras.localPosition, (x) => { tras.localPosition = x; }, rTweeningAction.EndV3, rTweeningAction.Duration);
        }
        /// <summary>
        /// Postion
        /// </summary>
        /// <param name="rTweeningAction"></param>
        /// <param name="rGameObject"></param>
        public static void SetPostion_Behaviour(TweeningAction rTweeningAction, GameObject rGameObject)
        {
            var tras = rGameObject.GetComponent <Transform>();

            rTweeningAction.Tweener           = DOTween.To(() => tras.position, (x) => { tras.position = x; }, rTweeningAction.EndV3, rTweeningAction.Duration);
            rTweeningAction.SetPlayStartValue = () => { tras.position = rTweeningAction.StartV3; };
            rTweeningAction.SetDefultValue    = () => { tras.position = rTweeningAction.DefultVector3; };
        }
 /// <summary>
 /// Delay
 /// </summary>
 /// <param name="rTweeningAction"></param>
 /// <param name="rGameObject"></param>
 public static void SetDelay_Behaviour(TweeningAction rTweeningAction, GameObject rGameObject)
 {
     rTweeningAction.Tweener = DOTween.To(
         () => { return(0); },
         (x) => { },
         0,
         rTweeningAction.Duration
         );
 }
        /// <summary>
        /// LocalRotate
        /// </summary>
        /// <param name="rTweeningAction"></param>
        /// <param name="rGameObject"></param>
        public static void SetLocalRotate_Behaviour(TweeningAction rTweeningAction, GameObject rGameObject)
        {
            var tras = rGameObject.GetComponent <Transform>();
            TweenerCore <Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => tras.localRotation, (x) => { tras.localRotation = x; }, rTweeningAction.EndV3, rTweeningAction.Duration);

            t.plugOptions.rotateMode          = RotateMode.FastBeyond360;
            rTweeningAction.Tweener           = t;
            rTweeningAction.SetPlayStartValue = () => { tras.localEulerAngles = rTweeningAction.StartV3; };
            rTweeningAction.SetDefultValue    = () => { tras.eulerAngles = rTweeningAction.DefultVector3; };
        }
Example #5
0
        /// <summary>
        /// Rotate
        /// </summary>
        /// <param name="rTweeningAction"></param>
        /// <param name="rGameObject"></param>
        public static void SetRotate_Behaviour(TweeningAction rTweeningAction, GameObject rGameObject)
        {
            var tras = rGameObject.GetComponent <Transform>();

            tras.rotation = Quaternion.Euler(rTweeningAction.StartV3);
            TweenerCore <Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => tras.rotation, (x) => { tras.rotation = x; }, rTweeningAction.EndV3, rTweeningAction.Duration);

            t.plugOptions.rotateMode = RotateMode.FastBeyond360;
            rTweeningAction.Tweener  = t;
        }
Example #6
0
        /// <summary>
        /// CanvasAlpha
        /// </summary>
        /// <param name="rTweeningAction"></param>
        /// <param name="rGameObject"></param>
        public static void SetCanvasAlpha_Behaviour(TweeningAction rTweeningAction, GameObject rGameObject)
        {
            var canvasAlpha = rGameObject.GetComponent <CanvasGroup>();

            if (canvasAlpha != null)
            {
                canvasAlpha.alpha       = rTweeningAction.StartF;
                rTweeningAction.Tweener = DOTween.To(() => canvasAlpha.alpha, (x) => canvasAlpha.alpha = x, rTweeningAction.EndF, rTweeningAction.Duration);
            }
        }
        public static void CreateTweenBehaviour(TweeningAction rTweeningAction, GameObject rGameObject)
        {
            var rActionType = rTweeningAction.Type;

            switch (rActionType)
            {
            case TweeningActionType.Position:
                SetPostion_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.LocalPosition:
                SetLocalPostion_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.Rotate:
                SetRotate_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.LocalRotate:
                SetLocalRotate_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.LocalScale:
                SetLocalScale_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.Color:
                SetColor_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.CanvasAlpha:
                SetCanvasAlpha_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.Delay:
                SetDelay_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.ImageAmount:
                SetImageAmount_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.RectTransPos:
                SetRectTransPos_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.RectTransPosX:
                SetRectTransPosX_Behaviour(rTweeningAction, rGameObject);
                break;

            case TweeningActionType.RectTransPosY:
                SetRectTransPosY_Behaviour(rTweeningAction, rGameObject);
                break;
            }
        }
        private static void SetRectTransPosY_Behaviour(TweeningAction rTweeningAction, GameObject rGameObject)
        {
            var rRectTrans = rGameObject.GetComponent <RectTransform>();

            if (rRectTrans != null)
            {
                rTweeningAction.SetDefultValue    = () => { rRectTrans.anchoredPosition = new Vector2(rRectTrans.anchoredPosition.x, rTweeningAction.DefultFloat); };
                rTweeningAction.SetPlayStartValue = () => { rRectTrans.anchoredPosition = new Vector2(rRectTrans.anchoredPosition.x, rTweeningAction.StartF); };
                rTweeningAction.Tweener           = DOTween.To(
                    () => { return(rRectTrans.anchoredPosition.y); },
                    (y) => { rRectTrans.anchoredPosition = new Vector2(rRectTrans.anchoredPosition.x, y); },
                    rTweeningAction.EndF,
                    rTweeningAction.Duration);
            }
        }
        private static void SetRectTransPos_Behaviour(TweeningAction rTweeningAction, GameObject rGameObject)
        {
            var rRectTrans = rGameObject.GetComponent <RectTransform>();

            if (rRectTrans != null)
            {
                rTweeningAction.SetDefultValue    = () => { rRectTrans.anchoredPosition = rTweeningAction.DefultVector3; };
                rTweeningAction.SetPlayStartValue = () => { rRectTrans.anchoredPosition = rTweeningAction.StartV3; };
                rTweeningAction.Tweener           = DOTween.To(
                    () => { return(new Vector2(rRectTrans.anchoredPosition.x, rRectTrans.anchoredPosition.y)); },
                    (x) => { rRectTrans.anchoredPosition = x; },
                    new Vector2(rTweeningAction.EndV3.x, rTweeningAction.EndV3.y),
                    rTweeningAction.Duration);
            }
        }
        public static void SetImageAmount_Behaviour(TweeningAction rTweeningAction, GameObject rGameObject)
        {
            var rImage = rGameObject.GetComponent <Image>();

            if (rImage != null)
            {
                rTweeningAction.SetDefultValue    = () => { rImage.fillAmount = rTweeningAction.DefultFloat; };
                rTweeningAction.SetPlayStartValue = () => { rImage.fillAmount = rTweeningAction.StartF; };
                rTweeningAction.Tweener           = DOTween.To(
                    () => { return(rImage.fillAmount); },
                    (x) => { rImage.fillAmount = x; },
                    rTweeningAction.EndF,
                    rTweeningAction.Duration);
            }
        }
Example #11
0
        private void SetUpTweener(TweeningAction rTweenAction)
        {
            if (rTweenAction.Tweener == null)
            {
                return;
            }

            // 先暂停
            rTweenAction.Tweener.Pause();
            rTweenAction.Tweener.SetUpdate(this.IsUseFixedUpdate ? UpdateType.Fixed : UpdateType.Normal, false);
            rTweenAction.Tweener.timeScale = this.IsIgnoreTimeScale ? Time.timeScale : 1;
            rTweenAction.Tweener.SetEase(rTweenAction.TimeCurve);
            // 是否循环
            if (rTweenAction.IsLoop)
            {
                rTweenAction.Tweener.SetLoops(rTweenAction.LoopCount, rTweenAction.LoopType);
            }
        }
Example #12
0
        /// <summary>
        /// Color
        /// </summary>
        /// <param name="rTweeningAction"></param>
        /// <param name="rGameObject"></param>
        public static void SetColor_Behaviour(TweeningAction rTweeningAction, GameObject rGameObject)
        {
            var meshRenderers = rGameObject.GetComponents <MeshRenderer>();

            if (meshRenderers != null && meshRenderers.Length > 0)
            {
                foreach (var item in meshRenderers)
                {
                    item.material.color = rTweeningAction.StartCol;
                }
                rTweeningAction.Tweener = DOTween.To(
                    () => meshRenderers[0].material.color,
                    (x) => {
                    foreach (var item in meshRenderers)
                    {
                        item.material.color = x;
                    }
                },
                    rTweeningAction.EndCol,
                    rTweeningAction.Duration
                    );
            }

            var graphics = rGameObject.GetComponents <Graphic>();

            if (graphics != null && graphics.Length > 0)
            {
                foreach (var item in graphics)
                {
                    item.color = rTweeningAction.StartCol;
                }
                rTweeningAction.Tweener = DOTween.To(
                    () => graphics[0].color,
                    (x) => {
                    foreach (var item in graphics)
                    {
                        item.color = x;
                    }
                },
                    rTweeningAction.EndCol,
                    rTweeningAction.Duration
                    );
            }
        }