[TestCase("#FFFFFF", 1f, 1f, 1f, 1f)] // rgb: 255,255,255 public void HextoColor_DoesValidConversion(string hex, float r, float g, float b, float a) { AssertColorsEqual(new Color(r, g, b, a), MaterialUtils.HexToColor(hex)); }
/// <summary> /// Setup Unity branded swatches and gradients /// </summary> static void SetupUnityBrandColors() { s_Red = MaterialUtils.HexToColor("F44336"); s_RedLight = MaterialUtils.HexToColor("FFEBEE"); s_RedDark = MaterialUtils.HexToColor("B71C1C"); s_Magenta = MaterialUtils.HexToColor("E91E63"); s_MagentaLight = MaterialUtils.HexToColor("FCE4EC"); s_MagentaDark = MaterialUtils.HexToColor("880E4F"); s_Purple = MaterialUtils.HexToColor("9C27B0"); s_PurpleLight = MaterialUtils.HexToColor("F3E5F5"); s_PurpleDark = MaterialUtils.HexToColor("4A148C"); s_Blue = MaterialUtils.HexToColor("03A9F4"); s_BlueLight = MaterialUtils.HexToColor("E1F5FE"); s_BlueDark = MaterialUtils.HexToColor("01579B"); s_Cyan = MaterialUtils.HexToColor("00BCD4"); s_CyanLight = MaterialUtils.HexToColor("E0F7FA"); s_CyanDark = MaterialUtils.HexToColor("006064"); s_Teal = MaterialUtils.HexToColor("009688"); s_TealLight = MaterialUtils.HexToColor("E0F2F1"); s_TealDark = MaterialUtils.HexToColor("004D40"); s_Green = MaterialUtils.HexToColor("8AC249"); s_GreenLight = MaterialUtils.HexToColor("F1F8E9"); s_GreenDark = MaterialUtils.HexToColor("33691E"); s_Lime = MaterialUtils.HexToColor("CDDC39"); s_LimeLight = MaterialUtils.HexToColor("F9FBE7"); s_LimeDark = MaterialUtils.HexToColor("827717"); s_Yellow = MaterialUtils.HexToColor("FFEB3B"); s_YellowLight = MaterialUtils.HexToColor("FFFDE7"); s_YellowDark = MaterialUtils.HexToColor("F57F17"); s_Orange = MaterialUtils.HexToColor("FF9800"); s_OrangeLight = MaterialUtils.HexToColor("FFF3E0"); s_OrangeDark = MaterialUtils.HexToColor("E65100"); s_DarkBlue = MaterialUtils.HexToColor("222C37"); s_DarkBlueLight = MaterialUtils.HexToColor("E9EBEC"); s_Dark = MaterialUtils.HexToColor("323333"); s_Darker = MaterialUtils.HexToColor("1A1A1A"); s_Light = MaterialUtils.HexToColor("F5F8F9"); // Set default neutral(luma) swatches s_ColorSwatches.Add(s_Red); s_ColorSwatches.Add(s_Magenta); s_ColorSwatches.Add(s_Purple); s_ColorSwatches.Add(s_Blue); s_ColorSwatches.Add(s_Cyan); s_ColorSwatches.Add(s_Teal); s_ColorSwatches.Add(s_Green); s_ColorSwatches.Add(s_Lime); s_ColorSwatches.Add(s_Yellow); s_ColorSwatches.Add(s_Orange); // cache standard color swatch list size s_ColorSwatchRange = s_ColorSwatches.Count - 1; // Setup default session gradient; can be set with a random gradient externally, // allowing all UI objects fetching this gradient to have a uniform color-scheme sessionGradient = new GradientPair(s_Light, s_Dark); // Setup grayscale light/dark contrasting session gradient grayscaleSessionGradient = new GradientPair(MaterialUtils.HexToColor("898A8AFF"), s_Light); darkGrayscaleSessionGradient = new GradientPair(MaterialUtils.HexToColor("636565FF"), MaterialUtils.HexToColor("484949FF")); // Setup neutral-luma curated gradient pairs s_CuratedGradientPairs.Add(new GradientPair(cyan, blueDark)); s_CuratedGradientPairs.Add(new GradientPair(teal, tealDark)); s_CuratedGradientPairs.Add(new GradientPair(green, tealDark)); s_CuratedGradientPairs.Add(new GradientPair(lime, tealDark)); s_CuratedGradientPairs.Add(new GradientPair(orange, redDark)); s_CuratedGradientPairs.Add(new GradientPair(orange, magenta)); s_CuratedGradientPairs.Add(new GradientPair(red, darker)); s_CuratedGradientPairs.Add(new GradientPair(lime, red)); s_CuratedGradientPairs.Add(new GradientPair(lime, cyan)); s_CuratedGradientPairs.Add(new GradientPair(lime, greenDark)); s_CuratedGradientPairs.Add(new GradientPair(lime, cyanDark)); s_CuratedGradientPairs.Add(new GradientPair(lime, darker)); s_CuratedGradientPairs.Add(new GradientPair(lime, darkBlue)); s_CuratedGradientPairs.Add(new GradientPair(lime, limeDark)); s_CuratedGradientPairs.Add(new GradientPair(lime, magenta)); s_CuratedGradientPairs.Add(new GradientPair(magenta, purpleDark)); s_CuratedGradientPairs.Add(new GradientPair(magenta, yellow)); s_CuratedGradientPairs.Add(new GradientPair(blue, purpleDark)); s_CuratedGradientPairs.Add(new GradientPair(blue, cyanDark)); s_CuratedGradientPairs.Add(new GradientPair(blue, blueDark)); s_CuratedGradientPairs.Add(new GradientPair(blue, blueDark)); s_CuratedGradientPairs.Add(new GradientPair(red, darkBlue)); s_CuratedGradientPairs.Add(new GradientPair(blue, darkBlue)); s_CuratedGradientPairs.Add(new GradientPair(yellow, red)); s_CuratedGradientPairs.Add(new GradientPair(red, blue)); s_CuratedGradientPairs.Add(new GradientPair(magenta, cyan)); s_CuratedGradientPairs.Add(new GradientPair(blue, magenta)); s_CuratedGradientPairs.Add(new GradientPair(blue, purple)); s_CuratedGradientPairs.Add(new GradientPair(magenta, darker)); // Setup dark-luma curated gradient pairs s_CuratedDarkGradientPairs.Add(new GradientPair(tealDark, darkBlue)); s_CuratedDarkGradientPairs.Add(new GradientPair(blueDark, darkBlue)); s_CuratedDarkGradientPairs.Add(new GradientPair(redDark, darkBlue)); s_CuratedDarkGradientPairs.Add(new GradientPair(yellowDark, darkBlue)); s_CuratedDarkGradientPairs.Add(new GradientPair(cyanDark, darkBlue)); s_CuratedDarkGradientPairs.Add(new GradientPair(greenDark, darkBlue)); s_CuratedDarkGradientPairs.Add(new GradientPair(purpleDark, darkBlue)); s_CuratedDarkGradientPairs.Add(new GradientPair(darkBlueLight, darkBlue)); // Setup light-luma curated gradient pairs s_CuratedLightGradientPairs.Add(new GradientPair(redLight, tealDark)); s_CuratedLightGradientPairs.Add(new GradientPair(yellowLight, tealDark)); s_CuratedLightGradientPairs.Add(new GradientPair(orangeLight, limeDark)); s_CuratedLightGradientPairs.Add(new GradientPair(yellowLight, blueDark)); s_CuratedLightGradientPairs.Add(new GradientPair(yellowLight, cyanDark)); s_CuratedLightGradientPairs.Add(new GradientPair(orangeLight, greenDark)); s_CuratedLightGradientPairs.Add(new GradientPair(cyanLight, orange)); s_CuratedLightGradientPairs.Add(new GradientPair(yellowLight, purple)); s_CuratedLightGradientPairs.Add(new GradientPair(yellowLight, blue)); s_CuratedLightGradientPairs.Add(new GradientPair(orangeLight, lime)); s_CuratedLightGradientPairs.Add(new GradientPair(redLight, darkBlue)); s_CuratedLightGradientPairs.Add(new GradientPair(blueLight, yellow)); s_CuratedLightGradientPairs.Add(new GradientPair(blueLight, yellowDark)); s_CuratedLightGradientPairs.Add(new GradientPair(greenLight, red)); }