Dotween的一些封装

 /// <summary>
    /// 颜色
    /// </summary>
    /// <param name="spriteRenderer"></param>
    /// <param name="color"></param>
    public void DoColor(SpriteRenderer spriteRenderer, Color color, Action action = null)
    {
        if (spriteRenderer == null)
        {
            return;
        }
        Tweener tweener = spriteRenderer.DOColor(color, 2);
        tweener.SetEase(Ease.Linear);
        tweener.onComplete = delegate ()
        {
            action?.Invoke();
        };
    }
    /// <summary>
    /// 移动
    /// </summary>
    /// <param name="Pos"></param>
    /// <param name="Trans"></param>
    /// <param name="Times"></param>
    /// <param name="action"></param>
    public void Move(Transform Pos, Vector3 Trans, float Times, Action action = null)
    {
        if (Pos == null)
        {
            return;
        }
        Tweener tweener = Pos.transform.DOMove(Trans, Times);
        tweener.SetEase(Ease.Linear);
        tweener.onComplete = delegate ()
        {
            action?.Invoke();
        };
    }
    public void LocalMove(Transform Pos, Vector3 Trans, float Times, Action action = null)
    {
        Tweener tweener = Pos.transform.DOLocalMove(Trans, Times);
        tweener.SetEase(Ease.Linear);
        tweener.onComplete = delegate ()
        {
            action?.Invoke();
        };
    }
    /// <summary>
    /// 渐变
    /// </summary>
    /// <param name="Pos"></param>
    /// <param name="Value"></param>
    /// <param name="Times"></param>
    /// <param name="action"></param>
    /// <returns></returns>
    public void Group(CanvasGroup Pos, float Value, float Times, Action action = null)
    {
        Tweener tweener = Pos.DOFade(Value, Times);
        tweener.SetEase(Ease.Linear);
        tweener.onComplete = delegate ()
        {
            action?.Invoke();
        };
    }
    /// <summary>
    /// 缩放
    /// </summary>
    /// <param name="Pos"></param>
    /// <param name="Trans"></param>
    /// <param name="Times"></param>
    /// <param name="action"></param>
    public void Scales(Transform Pos, Vector3 Trans, float Times, Action action = null, bool Set = false,LoopType type=LoopType.Yoyo)
    {
        Tweener tweener = Pos.transform.DOScale(Trans, Times);
        tweener.SetEase(Ease.Linear);
        if (Set == true)
        {
            tweener.SetLoops(-1, type);
        }
        tweener.onComplete = delegate ()
        {
            action?.Invoke();
        };
    }
   
    /// <summary>
    /// 旋转
    /// </summary>
    /// <param name="Pos"></param>
    /// <param name="Trans"></param>
    /// <param name="Times"></param>
    /// <param name="action"></param>
    public void Rotations(Transform Pos, Vector3 Trans, float Times, Action action = null)
    {
        if (Pos == null)
        {
            return;
        }
        Tweener tweener = Pos.transform.DORotate(Trans, Times);
        tweener.SetEase(Ease.Linear);
        tweener.onComplete = delegate ()
        {
            action?.Invoke();
        };
    }
    public void LocalRotations(Transform Pos, Vector3 Trans, float Times, Action action = null)
    {
        if (Pos == null)
        {
            return;
        }
        Tweener tweener = Pos.transform.DOLocalRotate(Trans, Times);
        tweener.SetEase(Ease.Linear);
        tweener.onComplete = delegate ()
        {
            action?.Invoke();
        };
    }
    public void Quaternions(Transform Pos, Quaternion Trans, float Times, Action action = null)
    {
        if (Pos == null)
        {
            return;
        }
        Tweener tweener = Pos.transform.DORotateQuaternion(Trans, Times);
        tweener.SetEase(Ease.Linear);
        tweener.onComplete = delegate ()
        {
            action?.Invoke();
        };
    }
    public void LocalQuaternions(Transform Pos, Quaternion Trans, float Times, Action action = null)
    {
        if (Pos == null)
        {
            return;
        }
        Tweener tweener = Pos.transform.DOLocalRotateQuaternion(Trans, Times);
        tweener.SetEase(Ease.Linear);
        tweener.onComplete = delegate ()
        {
            action?.Invoke();
        };
    }
    /// <summary>
    /// 看向
    /// </summary>
    /// <param name="Pos"></param>
    /// <param name="Trans"></param>
    /// <param name="Times"></param>
    /// <param name="action"></param>
    public void Look(Transform Pos, Vector3 Trans, float Times, Action action = null)
    {
        if (Pos == null)
        {
            return;
        }
        Tweener tweener = Pos.transform.DOLookAt(Trans, Times);
        tweener.SetEase(Ease.Linear);
        tweener.onComplete = delegate ()
        {
            action?.Invoke();
        };
    }
    /// <summary>
    ///第一个参数 punch:表示方向及强度
    ///第二个参数 duration:表示动画持续时间
    ///第三个参数 vibrato:震动次数
    ///第四个参数 elascity: 这个值是0到1的
    ///当为0时,就是在起始点到目标点之间运动
    ///为0时,会把你赋的值乘上一个参数,作为你运动方向反方向的点,物体在这个点和目标点之间运动
    /// </summary>
    /// <param name="Pos"></param>
    /// <param name="Punch"></param>
    /// <param name="duration"></param>
    /// <param name="vibrato"></param>
    /// <param name="elascity"></param>
    /// <param name="action"></param>
    public void PunchPos(Transform Pos, Vector3 Punch, float duration, int vibrato, float elascity, Action action = null)
    {
        if (Pos == null)
        {
            return;
        }
        Tweener tweener = Pos.transform.DOPunchP
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值