Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1.         /*Converte cor pra Hex*/
  2.         public static string ColorToHex(Color32 color) {
  3.             string hex = color.r.ToString("X2") + color.g.ToString("X2") + color.b.ToString("X2");
  4.             return hex;
  5.         }
  6.         /*Converte Hex pra cor*/
  7.         public static Color HexToColor(string hex) {
  8.             byte r = byte.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
  9.             byte g = byte.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
  10.             byte b = byte.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
  11.             return new Color32(r, g, b, 255);
  12.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement