DoTween 实现 TextMeshPro 打字效果

Text用DoTween的DoText()方法可以实现打字效果,但现在使用TMP较多,目前DoTween 好像没有TMP的拓展方法,但可以使用DoTween通用方法实现。

通用方法:DOTween.To( getter, setter, endValue, float duration )

using UnityEngine;
using DG.Tweening;
using TMPro;

public class Test : MonoBehaviour
{
    public TextMeshProUGUI tmp;

    void Start()
    {
        string text = tmp.text;
        DOTween.To(() => string.Empty, value => tmp.text = value, text, 3f).SetEase(Ease.Linear);
    }

}

猜你喜欢

转载自blog.csdn.net/qq_52406653/article/details/128072394