How to change material color of an Object

Guys, how may i change the tint color of a material in a existent GameObject in JavaScript?

gameObject.renderer.material.color = Color.white;

You have to either define a color, or you can use Color.white ('white' can be any of a number of colors, including white, red, yellow, black, gray, blue, cyan, green, etc.)

Or build your own Color using Color(R, G, B). R, G, & B in this function are floats from 0.0 to 1.0.

This works best if the base color of the material is 50% gray, that way you have room to move away from that color in any direction.

The actual effect of this is that you are adjusting the 'Main Color' of the material that is exposed in the Inspector at the top of the material.

You do not have to do it with code if you want to make it a bit easier. Just left click in your preferred folder in this case Assets and then create–>Material. From there you can change in to a sprite if you want a solid color and you can experiment with them. Once you have the proper color just drag that material into the object.

allo!

When i use

gameObject.renderer.material.color = Color(0.777, 08, 0.604);

the color is not the same as when I use this color in the object.

if anyone knows why, thank you

In Unity 2019+, C#:

gameObject.GetComponent<Renderer>().material.color = Color.white;

http://solution2tech.blogspot.in/2013/10/change-material-color-in-unity-3d.html

If you need more complex recoloring (keeping some colors intact while changing other etc.), you can check Colorify on asset store