How do you show/hide textUI in Javascript?
I have searched for an hour looking for somebody who explains how to do this in Javascript. I need to show and hide my text objects by the press of a button and here is my current code. I need something similar to .enabled or .setactive but I get errors from both of them.
.setactive only seems to work for objects because I get the error that setactive and enabled are not apart of UI.Text.
My varibles are defined as
var woodText : UI.Text;
My key pressing code
if(showGUI == true)
{
inventoryPanel.SetActive(true);
Time.timeScale = 0;
}
if(showGUI == false)
{
inventoryPanel.SetActive(false);
Time.timeScale = 1;
}
}
Answer by DiegoSLTS · May 30, 2016 at 11:56 PM
UI.Text has the enabled property, inherited from Behaviour: http://docs.unity3d.com/ScriptReference/UI.Text.html
If you can't use that you have some other problem in your script.
If you want to use SetActive instead (which disables a whole GameObject instead of just a component) you need the gameObject first:
woodText.gameObject.SetActive(true); //or false
Thank you so much, I could not find that in the documentation or anywhere!
Your answer
Follow this Question
Related Questions
Space Shooter Tutorial GUI is not working 1 Answer
how can i create an interactive text in GUI.Window? 0 Answers
How to know if the unicode entered into TMP Text is returning a character from the given fonts? 0 Answers
How do You add a Scrollbar in a textbox C# code 0 Answers
Gui Text won't turn off 0 Answers