代码语言:javascript复制
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class PingPong : MonoBehaviour {
float m_time = 0.5f;
Transform m_trans;
// Use this for initialization
void Start()
{
m_trans = transform;
MyPingPong(m_trans.localPosition.y,m_trans.localPosition.y 0.1f);
}
private void MyPingPong(float from, float to)
{
m_trans.DOLocalMoveY(to, m_time).OnComplete(() => MyPingPong(to, from));
}
}