zoukankan      html  css  js  c++  java
  • 常用自制脚本(一):透明度统一修改

    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    /// <summary>
    /// User interface alpha ctrl.
    /// 统一控制图片的透明度
    /// </summary>
    public class UIAlphaCtrl : MonoBehaviour {
            Image[] images;
            Text[] texts;
            Color[] c_Images;
            Color[] c_Texts;
    
    	void Awake () {
                    GetChildren ();  
    	}
            void GetChildren(){                
                    images = GetComponentsInChildren<Image>();
                    texts = GetComponentsInChildren<Text> ();
                    c_Images = new Color[images.Length];
                    c_Texts = new Color[texts.Length];
                    for (int i = 0; i < images.Length; i++) {
                            c_Images [i] = images [i].color;
                    }
                    for (int i = 0; i < texts.Length; i++) {
                            c_Texts [i] = texts [i].color;
                    }
            }
            public void ChangeAlpha(float alpha){                
                    for (int i = 0; i < images.Length; i++) {
                            c_Images [i].a = alpha;
                            images [i].color = c_Images [i];
                    }
                    for (int i = 0; i < texts.Length; i++) {
                            c_Texts [i].a =alpha;
                            texts [i].color = c_Texts [i];
                    }
            }
    }
    

     注意:

      将目标UI归纳到一个对象下,并绑该脚本

      

  • 相关阅读:
    apache域名跳转
    apache配置防盗链
    apache配置静态缓存
    apache通过rewrite限制某个目录
    apache不记录指定类型的访问日志
    apache访问日志
    apache用户认证
    apache访问控制
    apache禁止默认虚拟主机
    mysql主从复制架构配置
  • 原文地址:https://www.cnblogs.com/chimo523/p/5227239.html
Copyright © 2011-2022 走看看