Framework/Assets/TestScripts/DoTweenTest/DoTweenTest.cs

23 lines
629 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DoTweenTest : MonoBehaviour
{
public Vector3 targetPosition; // 目标位置
public float duration = 2f; // 移动到目标位置的时间
private Vector3 startPosition; // 起始位置
void Start()
{
startPosition = transform.position; // 记录起始位置
// 创建一个来回循环的移动动画
transform.DOMove(targetPosition, duration)
.SetEase(Ease.Linear) // 设置缓动类型为线性
.SetLoops(-1, LoopType.Yoyo); // 设置无限循环循环类型为Yoyo来回
}
}