一、步骤
1.新建一个场景(命名为:007_textColorTweens)
2.创建text控件
3.在text底下添加一个脚本组件(add Component -> 命脚本的名字为:textColorTween)
4.编辑脚本
5.动画设置字体颜色、动画设置字体的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.将当前的text 给属性赋值
// 使用 DOColor
// DOFade 渐影渐变
private Text text;
// Use this for initialization
void Start () {
text = GetComponent<Text> ();
/*
* 第一个参数是 : 目标颜色
*
*/
// text.DOColor (Color.red, 2);
// 渐影渐变
/**
* 第一个参数是 是否显示 ,1为显示出来
* 第二个参数是 执行时间
*/
text.DOFade(1,3);
}
// Update is called once per frame
void Update () {
}
}
11_5.1动画设置字体颜色
11_5.1动画设置字体颜色.gif
11_5.2动画设置字体的alpha
11_5.2动画设置字体的alpha.gif