# Issues changing object's color,Precisely chosing a color using rgb/hex

Hi!
Big unity newbie here!
I followed a tutorial that lead me to change a block’s color using these lines, but I am unnable to chose a custom color, i dont know what i’m missing for such a simple task

Sorry if the answer is obvious, again I am new to this

I once played around with Colors, and getting or setting their respective tints(hues). Here is a snippet of my older code, hopefully something helps you out :

``````/////////////////////
Color32 SetDefinedColor(Color32 color)
{
byte r = color.r;
byte g = color.g;
byte b = color.b;
byte a = 255;
byte half = 255 / 2;
if (r > half) { r = 255; } else { r = 0; }
if (b > half) { b = 255; } else { b = 0; }
if (g > half) { g = 255; } else { g = 0; }
color = new Color32(r, g, b, a);
return myColor;
}

Color32 SetColor(Color32 color)
{
byte r = color.r;
byte g = color.g;
byte b = color.b;
byte a = 255;
int div = 85;
int fraction = Mathf.RoundToInt(r / div) * div;
r = (byte)(fraction - 1);
fraction = Mathf.RoundToInt(g / div) * div;
g = (byte)(fraction - 1);
fraction = Mathf.RoundToInt(b / div) * div;
b = (byte)(fraction - 1);

color = new Color32(r, g, b, a);
return myColor;
}

Color32 SetQuarterColor(Color32 input)
{
byte r = input.r;
byte g = input.g;
byte b = input.b;
byte a = 255;

if (r < 32) { r = 0; }
else if (r > 0 && r < 64) { r = 64; }
else if (r > 64 && r < 128) { r = 128; }
else if (r > 128 && r < 192) { r = 192; }
else { r = 255; }

if (g < 32) { g = 0; }
else if (g > 0 && g < 64) { g = 64; }
else if (g > 64 && g < 128) { g = 128; }
else if (g > 128 && g < 192) { g = 192; }
else { g = 255; }

if (b < 32) { b = 0; }
else if (b > 0 && b < 64) { b = 64; }
else if (b > 64 && b < 128) { b = 128; }
else if (b > 128 && b < 192) { b = 192; }
else { b = 255; }

myColorQ = new Color32(r,g,b,a);
return myColorQ;
}
////////////////////////
Defined Colors:
white- 255,255,255,255
black- 000,000,000,255
red-   255,000,000,255
yellow-255,255,000,255
green- 000,255,000,255
cyan-  000,255,255,255
blue-  000,000,255,255
magenta255,000,255,255
``````

If I remember correctly, this snippet was for creating `tilemaps` from a image. So getting the color at position of the grid in the image, would then translate that data into a tile map. Basically making a 100x100 image a layout for a map. I then cut the colors into “rounded” colors(64(bit) colors) so even using an image with different colors, or shades of them, could still be read and interpreted.

This may look confusing(as it does to me now, lol), but I’m sure once you play around with it, and test it. You will have a new found love, and use, of colors.