- 在Unity中使用DOTweenPath组件测试的,代码如下:
using UnityEngine;
using DG.Tweening;
public class DOTweenTest : MonoBehaviour
{
Tween m_Tweener;
void Start()
{
m_Tweener = GetComponent<DOTweenPath>().GetTween();
m_Tweener.OnStart(OnStart);
m_Tweener.OnPlay(OnPlay);
m_Tweener.OnUpdate(OnUpdate);
m_Tweener.OnStepComplete(OnStepComplete);
m_Tweener.OnComplete(OnComplete);
m_Tweener.OnPause(OnPause);
m_Tweener.OnRewind(OnRewind);
m_Tweener.OnKill(OnKill);
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
Debug.Log("KeyDown Q");
}
else if (Input.GetKeyDown(KeyCode.Y))
{
Debug.Log("KeyDown Y DOPlay");
transform.DOPlay();
}
else if (Input.GetKeyDown(KeyCode.U))
{
Debug.Log("KeyDown U DORestart");
transform.DORestart();
}
else if (Input.GetKeyDown(KeyCode.I))
{
Debug.Log("KeyDown I DORewind");
transform.DORewind();
}
else if (Input.GetKeyDown(KeyCode.O))
{
Debug.Log("KeyDown O DOPlayBackwards");
transform.DOPlayBackwards();
}
else if (Input.GetKeyDown(KeyCode.P))
{
Debug.Log("KeyDown P DOFlip");
transform.DOFlip();
}
}
public void OnCreated()
{
Debug.Log("Tween OnCreated");
}
void OnStart()
{
Debug.Log("Tween OnStart");
}
void OnPlay()
{
Debug.Log("Tween OnPlay");
}
void OnUpdate()
{
Debug.Log("Tween OnUpdate");
}
void OnStepComplete()
{
Debug.Log("Tween OnStepComplete");
}
void OnComplete()
{
Debug.Log("Tween OnComplete");
}
void OnPause()
{
Debug.Log("Tween OnPause");
}
void OnRewind()
{
Debug.Log("Tween OnRewind");
}
void OnKill()
{
Debug.Log("Tween OnKill");
}
}
参考博客:Dotween常用方法详解 (这位大佬的博客写得很详细,在此特意感谢!需要了解更详细的,可查阅此博客)
|