一、步驟
1.新建一個場景(命名為:005_textTween)
2.創建一個text
3.創建一個腳本(myText)
4.之前對游戲物體做一個動畫 是通過Rect Transform
5.使用Dotween里面的一個方法DOText進行一個文本的動畫
(如果原來的text有文字,在動畫過程中把原有的文字替換掉)
二、code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; // 引用UI的命名空間
using DG.Tweening;
public class myText : MonoBehaviour {
private Text text; //文本
// Use this for initialization
void Start () {
text = this.GetComponent<Text> (); // 直接獲取游戲物體
text.DOText("DOText是用來動畫顯示text的,接下來,開始動畫了,效果是一個字一個字顯示的",4,);//richtextEnabled 第三個參數是一個富文本
}
// Update is called once per frame
void Update () {
}
}
9_1對話框文字動畫.gif