public Color ToColor() { switch (type.ToLower()) { case TYPE_HEX: return(ColorEx.HexToColor(hex)); case TYPE_RGB: return(new Color ( r: red / 255.0f, g: green / 255.0f, b: blue / 255.0f, a: 1.0f )); case TYPE_HSB: return(new ColorHSB ( hue: hue / 360.0f, saturation: saturation, brightness: brightness, alpha: 1.0f ).ToColor()); default: throw new NotSupportedException($"Color type \"{type}\" not supported, valid values are: {TYPE_HEX}, {TYPE_RGB} and {TYPE_HSB}"); } }
CarColors loadDefaultColors(GameObject car) { for (int i = 0; i < car.transform.childCount; i++) { var c = car.transform.GetChild(i).gameObject; var n = c.name.ToLower(); if (n.Contains("defaultcolor")) { for (int j = 0; j < c.transform.childCount; j++) { var o = c.transform.GetChild(j).gameObject; var name = o.name.ToLower(); if (!name.StartsWith("#")) { continue; } name = name.Remove(0, 1); //remove # var s = name.Split(';'); if (s.Length != 2) { continue; } CarColors cc; Color color = ColorEx.HexToColor(s[1]); color.a = 1; if (s[0] == "primary") { cc.primary_ = color; } else if (s[0] == "secondary") { cc.secondary_ = color; } else if (s[0] == "glow") { cc.glow_ = color; } else if (s[0] == "sparkle") { cc.sparkle_ = color; } } } } return(m_infos.defaultColors); }