一、步驟
1.新建一個(gè)場(chǎng)景(命名為:007_textColorTweens)
2.創(chuàng)建text控件
3.在text底下添加一個(gè)腳本組件(add Component -> 命腳本的名字為:textColorTween)
4.編輯腳本
5.動(dòng)畫(huà)設(shè)置字體顏色、動(dòng)畫(huà)設(shè)置字體的alpha
二、code
textColorTween
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class TextColorTween : MonoBehaviour {
// 1.引入命名空間
// 2.定義屬性
// 3.將當(dāng)前的text 給屬性賦值
// 使用 DOColor
// DOFade 漸影漸變
private Text text;
// Use this for initialization
void Start () {
text = GetComponent<Text> ();
/*
* 第一個(gè)參數(shù)是 : 目標(biāo)顏色
*
*/
// text.DOColor (Color.red, 2);
// 漸影漸變
/**
* 第一個(gè)參數(shù)是 是否顯示 ,1為顯示出來(lái)
* 第二個(gè)參數(shù)是 執(zhí)行時(shí)間
*/
text.DOFade(1,3);
}
// Update is called once per frame
void Update () {
}
}
11_5.1動(dòng)畫(huà)設(shè)置字體顏色

11_5.1動(dòng)畫(huà)設(shè)置字體顏色.gif
11_5.2動(dòng)畫(huà)設(shè)置字體的alpha

11_5.2動(dòng)畫(huà)設(shè)置字體的alpha.gif