unity3d插件

u3d_插件DoTween:(11)颜色和透明度动画

2017-04-24  本文已影响3392人  liyuhong165
一、步骤
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
上一篇 下一篇

猜你喜欢

热点阅读