- Home /
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 ?
Answer by Wolfram · May 23, 2011 at 04:14 PM
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).
Answer by Joshua · May 23, 2011 at 04:06 PM
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.
All I'm trying to do is show / hide my gui texture when I press the $$anonymous$$ or N keys. I'm putting this script ontop of my already made gui texture labeled "playerbag"
Your answer
![](https://koobas.hobune.stream/wayback/20220612083402im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
hide and show gui texture problem 2 Answers
Organize around inactive GameObjects not being findable 0 Answers
How to find Inactive GameObject 16 Answers
Show/hide GUI texture 2 Answers