예제 #1
0
        public static Color GetColor(this JsonData json, string key, float alpha = 1)
        {
            Color color = Color.white;

            if (json != null && json.ContainsKey(key))
            {
                string value = json[key].ToString();

                if (string.IsNullOrEmpty(value))
                {
                    color.a = alpha;
                }
                else
                {
                    if (value.Substring(0, 1) != "#")
                    {
                        value = "#" + value;
                    }
                    ColorUtility.TryParseHtmlString(value, out color);
                }
            }
            return(color);
        }