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; } } }

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM