How do you add graphics and features to a GUI Window?

How do you add graphics to a GUI Window? For example: a background.

Also how do you add a 3D Text or label thing into a GUI Window?


var endTime : float;

var textMesh : TextMesh;

var boolean = false;
var windowRect = Rect(0,0,360,480);

function Start()
    endTime = Time.time +60;

    textMesh = GameObject.Find ("Timer").GetComponent(TextMesh);

    textMesh.text = "60";


function Update () {

    var timeLeft : int = endTime - Time.time;

    if ( timeLeft < 0)
        timeLeft = 0;
        boolean = true;
    textMesh.text = timeLeft.ToString();

function OnGUI() {

    if(boolean) GUI.WIndow (0, windowRect,DoMyWindow, "My Window");


function DoMyWindow (windowID : int) {

    if( GUI.Button(Rect(10,20,100,20),"HelloWorld"))  
    print ("Got a click");

When you call the window function, you need to pass a function to it as a parameter

That function gets called when the window draws

What you need to do is add your Label into that function, and it should just draw it, with the coordinates starting at 0,0 for the top left of the window

To draw a background, use GUI.DrawTexture in that function with the same size as the window and 0,0 for x and y


To make your window only show when you trigger it, you can just use a bool to set whether to draw or not

//at the top of the script
var yourBool = false;

//the code which is going to draw the window
if (yourBool) GUI.Window(blah blah);

//in the trigger
yourBool = true;