using UnityEngine; using UnityEngine.UI; using System.Collections; public static class ExtensionAlpha { public static void SetAlpha(this Graphic graphic, float alpha) { graphic.color = new Color(graphic.color.r, graphic.color.g, graphic.color.b, alpha); } public static void SetAlpha(this Material material, string propertyName, float alpha) { Color color = material.GetColor(propertyName); color.a = alpha; material.SetColor(propertyName, color); } public static void SetAlpha(this TextMesh textMesh, float alpha) { textMesh.color = new Color(textMesh.color.r, textMesh.color.g, textMesh.color.b, alpha); } public static void SetAlpha(this SpriteRenderer sR, float alpha) { sR.color = new Color(sR.color.r, sR.color.g, sR.color.b, alpha); } public static float GetAlpha(this Material material, string propertyName) { Color color = material.GetColor(propertyName); return color.a; } }