Simple question about materials

Hello!

I’ve googled alot and tried many things but I still can’t change color of a cube.
I use C#, where I create a cube through GameObject.CreatePrimitive(PrimitiveType.Cube).
I want it to be a specific color, in this case RGB(30, 225, 86). What’s the shortest code for doing that? Also I wonder, if you create a material manually in the editor, how can you apply that material to an object through scripting?

Thanks!

Did you read this? http://unity3d.com/support/documentation/ScriptReference/Material.Material.html

To set it in the editor, try setting the sharedMaterial rather than the material on the renderer.

Be sure to see this line:

cube.renderer.material = new Material (Shader.Find(" Glossy"));