functions inside functions

how do i call the OnGUI function from inside a function

fuction Update (){



if blah blah is true

function OnGUI ()
{

GUI.Box (Rect (10,10,100,90), "like this ");
}
}

i really dont understand why nothing i try works .

A functeption !

There is a bunch of function prepared for you by Unity (Update, Start, Awake, OnGUI, FixedUpdate etc) which are called by Unity at a specific time, without you seeing that call. So all you have to do, is implement them, and let good guy Unity take care of the rest.

By the way, you can’t declare a function inside an other one. Declare Update(), implement it {}, then declare OnGUI(), and implement it as well {}.

You don’t need to call OnGUI inside Update function(and it will not work, actually) to add an if statement. You can add if statement inside GUI function, like so:

function OnGUI() {

if(blah blah) {

GUI.Box (Rect (10,10,100,90), "like this ");
}

`}

Hope is that what you’re looking for (: