unity更改文字透明度

话不多说,直接上代码。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class testtest : MonoBehaviour {
    Color changeColor;
    public Text TextTest;
    // Use this for initialization
    void Start ()
    {
        changeColor = TextTest.color;

    }

    // Update is called once per frame
    void Update () {
		if(Input.GetKeyDown(KeyCode.A))
        {
            //白色半透明
            changeColor.r = 1f;
            changeColor.g =1f;
            changeColor.b = 1f;
            changeColor.a = 0.5f;
            TextTest.color = changeColor;
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
      //白色不透明 changeColor.a = 1f; changeColor.r = 1f; changeColor.g = 1f; changeColor.b = 1f; TextTest.color = changeColor; } } }

  

posted @ 2020-01-10 16:25  WalkingSnail  阅读(4246)  评论(0编辑  收藏  举报