gui refresh render

Hi,I have two situations and for each a GUI. A variable controls whether a button will show text only or with only a icon button.

var imageText : boolean = true;

//button that control if(GUI.Button (Rect (10, 210, 100, 15), "IMAGE OU TEXT")) { imageText = !imageText; }

if(imageText == true) { if (GUI.Button (Rect (5, 100, 50, 50), icon)) { }

}else{

  if (GUI.Button (Rect (5, k, 50, 50), text)) {
    }

}

the problem is that I even turning the button("IMAGE OU TEXT") and the control variable being altered my render no change of icon to text.

I just tested out your code. The problem occurs because as soon as OnGUI() is called, it looks at the Boolean value and immediately prints the GUI Button. So in effect there are 3 Gui Buttons being loaded. So the one with Icon is always loaded first. I modified the code where you actually check whether it is ready to load the GUI. Hope it helps.

var imageText : boolean = true;
var icon : Texture2D;
var readytoload = 0;

//button that control 
function OnGUI(){

if(GUI.Button (Rect (10, 210, 100, 15), "IMAGE OR TEXT"))
{
readytoload = 1;
imageText = !imageText; 
Debug.Log(imageText);
}

if(readytoload)
{
if(imageText)
if (GUI.Button (Rect (5, 100, 50, 50), icon)) 
{
imageText = true;
Debug.Log("Icon");
Debug.Log(imageText);
}

if(!imageText)
{
if (GUI.Button (Rect (205,100, 50, 50), "Text")) 
  {
  imageText = false;
  Debug.Log("Text");
  Debug.Log(imageText);
   }
   }
   }
}