C# - Setting color of a rect on creation

Rect rightArrowRect = new Rect(Screen.width1/2,0,Screen.width,Screen.height/6);
Rect leftArrowRect = new Rect(0,0,Screen.width
1/2,Screen.height/6);
Rect upArrowRect = new Rect(0,Screen.height/6,Screen.width,Screen.height/6);

For my interface, I am naming 3 rectangles as gui buttons. As of now, they are clear. How can I set the rectangle’s color on creation for each element? Everything I have read so far has to do with GUI something or others… Apologies for the lack of details, C# isn’t a code that I’m fairly familiar with.

Bonus: is there a way to set a small texture image to the center of each rect to make them easier to identify?

A Rect isn’t actually a renderable thing. You want something derived from Unity - Scripting API: GUIElement

like http://docs.unity3d.com/Documentation/ScriptReference/GUITexture.html perhaps.

The Rect structure does not contain information for color, this is something you’re going to have to change through the GUI buttons. When you call your GUI button you can apply the color you want through the GUI.backgroundColor property.

GUI.backgroundColor = Color.red;
GUI.Button( rect, "red button", guiStyle );

GUI.backgroundColor = Color.blue;
GUI.Button( rect, "blue button", guiStyle );

You can also do this through GUIStyles, which can be better if you want to do more with the style of the button, but will require more work.