Showing gui texture ?

I’m able to hide my gui texture by using this code

`

GameObject.Find(“playerbag”).guiTexture.active = false;

`

the only problem is it won’t show itself when I use this code.

`

GameObject.Find(“playerbag”).guiTexture.active = true;

`

Am I doing something wrong ?

You cannot Find() objects set to active==false. Search Unity Answers for several workarounds for this, for example, do the Find() in Start() (which you should do anyway, since it’s expensive) and then only use the reference variable for the object. Or, disable the GuiTexture, insted of deactivating it (use the bool guiTexture.enabled).

I’d need to see the script calling the GUI to effectively help you. But if the boolean you mention works, then if your code is of this structure:

var bool : boolean;
function OnGUI () { if(bool) { GUILayout.Label("Hello World"; } } 

Then the label will only be drawn if the boolean is true.