- Home /
This question was
closed Aug 25, 2014 at 06:45 PM by
meat5000 for the following reason:
The question is answered, right answer was accepted
Get text component uGUI
Guys, How do I get the text component on a Button by script on the new GUI? Thanks!
Comment
I use this
import UnityEngine.UI
var text : text;
function Start(){
text.GetComponent(Text);
text.text = "Hello"
}
Best Answer
Answer by Kaz_Yamof · Aug 25, 2014 at 06:42 PM
Nevermind. I forgot to set using UnityEngine.UI;
Answer by AyAMrau · Aug 25, 2014 at 06:37 PM
The Text component is actually on a child object of the button, so (assuming you have a Button reference called myButton):
myButton.GetComponentInChildren<Text>().text = "new text";
Follow this Question
Related Questions
uGUI Button size based on text size 1 Answer
Detect Text in GUI; Print 1 Answer
GUI text font change 3 Answers
Limit on GUI Components? 0 Answers
Unity GUI text displaying as noise 1 Answer