using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ConvertHelper {
///
/// 颜色 灰色
///
public static Color ColorGray = new Color(0.2f, 0.2f, 0.2f, 1.0f);
///
/// 设置游戏对象的透明度,包含 Image Text
///
/// 游戏对象
/// 透明度
public static void SetObjectAlpha(GameObject go, float a)
{
Image[] images = go.GetComponentsInChildren(true);
for (int i = 0; i < images.Length; i++)
{
Color color = images[i].color;
color.a = a;
images[i].color = color;
}
Text[] allText = go.GetComponentsInChildren(true);
for (int i = 0; i < allText.Length; i++)
{
Color color = allText[i].color;
color.a = a;
allText[i].color = color;
}
}
///
/// 设置游戏对象的颜色,包含 Image Text
///
/// 游戏对象
/// 颜色
public static void SetObjectColor(GameObject go, Color color)
{
Image[] images = go.GetComponentsInChildren(true);
for (int i = 0; i < images.Length; i++)
{
images[i].color = color;
}
Text[] allText = go.GetComponentsInChildren(true);
for (int i = 0; i < allText.Length; i++)
{
allText[i].color = color;
}
}
}