noobie GUI question

Hi all,

I am working away at learning how to script with unity, I started with Java script basics provided by the Walker Brothers tutorials and now I am going through their API tutorial. I am trying to display a small GUI box containing a string and the Time.realtimeSinceStartup.

I am using the code below but for some reason the box is not displaying, It seems to work for the guy on the video but not for me o0 (unless I am missing something obvious…) any help would be appreciated.

Thanks

function Update ()
{
print ( Time.realtimeSinceStartup );
}

function GuiTest()
{
GUI.Box (Rect (10, 10, 150, 100), "The current real time is:" + Time.realtimeSinceStartup);
}

The method wich is responsible for gui drawing should be named as OnGUI() instead of GuiTest()

How embarassing >.< , thank you that works perfectly. I just assumed it was a function name that he created.

With Unity, there are some ‘reserved’ function names. They are being called by Unity engine at the appropriate time.

This is a part of the messaging system. You could also make your own messages / method names to be used. Check out the SendMessage.