Creating Solid Colored Bg Rectangle With Code

I’m really new to Unity scripting (I come from a Flash AS2 and AS3 background), and I’m trying to create a solid 2 dimensional background.

In flash, I would do something like this:

var canvas:Sprite = new Sprite();
var gfx:Graphics = canvas.graphics;
gfx.drawRect(0,0,200,200,0x0);
addChild(canvas);

And that would place a solid black rectangle (200x200) at the point 0,0 on the stage. In Unity, I’ve been looking around at the built in GUI functions. I figured out how to manually create a GUI element, add a texture to it, and then make it solid black - however, this is all within the Unity UI. How would I do something like this with code (I’m using Javascript)

I was hoping to do something similar to this:

var color:int = 0x000000;//assuming colors are assigned in hexadecimal format
var width:int = 200;
var height:int = 200;
var x:int = 20;
var y:int = 20;

Gui.drawRectangle(x,y,width,height,color);

drawRectangle is not a Gui function, but is there something similar that will allow me to draw a simple rectangle? Do I have to manually create a material in the Unity UI?

Thanks for any help!
LaRue

You can just change the background color of the camera to black.

–Eric

Thanks! That’ll work perfectly for what I’m planning on doing. I didn’t even know that was possible.