DoTween实现打字机功能
NGUI里面有自带的打字机的功能,但是现在我们最常用的是UGUI,那么打字机可以用DoTween插件来实现:代码很简单,如下:
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
public class TyperExample : MonoBehaviour
{
private Text text;
void Awake()
{
text = GetComponent<Text>();
}
// Use this for initialization
void Start ()
{
text.DOText("原来你是我最想留住的幸运,原来我们的爱情曾经靠得那么近,那为我对抗世界的决定,那为我淋的雨,一幕幕都是你,一尘不染的真心", 10f).SetLoops(-1);
}
// Update is called once per frame
void Update () {
}
}
挂载在Text上面即可,效果如下:
关注一下公众号,回复关键字“打字机”即可获取源码和DoTween pro插件: