/// <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
Dotween的一些封装
最新推荐文章于 2023-05-02 21:37:16 发布