unity3d:dotween pingpong 物体来回运动

2023-08-24 14:54:00 浏览数 (2)

代码语言: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));
    }

}

0 人点赞