Unity Editor下运行DoTween动画
DOTweenEditorPreview.PrepareTweenForPreview(tar.GetTween());
DOTweenEditorPreview.Start();
以Test脚本为例:
public class UTest : MonoBehaviour
{
public Tween GetTween()
{
var tw= transform.DOMove(Vector3.left, 2);
tw.onUpdate = () =>
{
Debug.Log("afdsaf");
};
return tw;
}
}
[CustomEditor(typeof(UTest))]
public class UTestEditor : Editor
{
UTest tar;
void OnEnable()
{
tar = target as UTest;
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (GUILayout.Button("NN"))
{
DOTweenEditorPreview.PrepareTweenForPreview(tar.GetTween(),false);
DOTweenEditorPreview.Start();
}
}
}