- Home /
 
               Question by 
               Cyber_Defect · Sep 13, 2013 at 01:20 AM · 
                colorenumconstant  
              
 
              Enumerated Colors
Lets try this again.
I want to use an enum of colors but System.Drawing.KnownColor (http://msdn.microsoft.com/en-us/library/system.drawing.knowncolor.aspx) is not supported in Unity.
What is my best option?
               Comment
              
 
               
              Answer by Cyber_Defect · Sep 13, 2013 at 02:42 AM
I guess there is an easy solution afterall, I just need to use ConsoleColor instead of Color.
 public enum RarityTypes             {Common = ConsoleColor.Gray, Enchanted = ConsoleColor.White, Rare = ConsoleColor.Green, Heroic = ConsoleColor.Blue, Legendary = ConsoleColor.DarkMagenta, Unique = ConsoleColor.Yellow};
Answer by sooncat · Sep 13, 2013 at 03:10 AM
ConsoleColor is Different from Color.
I'd like to use this way(Create a Color file by VS)
             System.Array colorsArray = Enum.GetValues(typeof(KnownColor));
             KnownColor[] allColors = new KnownColor[colorsArray.Length];
 
             Array.Copy(colorsArray, allColors, colorsArray.Length);
             for (int i = 0; i < allColors.Length; i++)
             {
                 Color c = Color.FromName(allColors[i].ToString());
 
                 //first way :  crate an enum
                 Console.WriteLine(allColors[i] + " = " + c.ToArgb() + ",");
                 
                 //second way : crate a class
                 Console.WriteLine("public static Color " + allColors[i] + " = new Color32(" + c.R + "," + c.G + "," + c.B + "," + c.A + ");");
             }
How do you get $$anonymous$$nownColor to work in $$anonymous$$onoDevelop/unity?
The code works in VisualStudio not Unity. $$anonymous$$y destination is create a class which has an enum of color value. The class may works in Unity seperately.
Just Like this:
 public enum $$anonymous$$nownColor
     {
         ActiveBorder = -2830136,
         ActiveCaption = -16755485,
         ......
         $$anonymous$$enuBar = -1250856,
         $$anonymous$$enuHighlight = -13538619,
     }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                