How do I change the colour of a game-object?

Hey I’m new to unity and I’m making a map for my game. How can I change the colour of a game-object?(blue,red,green ex.)

Welcome to Unity.

Think of changing color of a cloth ball in real life. To do it, you change the cloth which is on top of it. Or you simply change the “Material” of the ball.

You need to create new material of appropriate color.
To do so
Assests → Create → Material.

alt text

Now in inspector, you can add the color of your choice.

alt text

Drag drop the material in the Mesh Renderer part of game object.

alt text

If the gameObject has only one material:

gameObject.renderer.material.color =;

If it can have multiple materials, or just to be sure in any case, you should use:

for (int i = 0; i < gameObject.renderer.materials.Length; i++) {
     gameObject.renderer.materials*.color =;*

Note the different words: “material” and “materials”.
Also note that the shader that the material uses has to have a color variable (the standard Diffuse shader has one, for example, but Vertex shaders often don’t).