- Home /
Question by
machinedude · Jan 14, 2013 at 05:31 AM ·
buttontextdynamically
Access button text dynamially
Hi guys,
Is there anyway to access the text of a button in code?
Thanks :)
Comment
Best Answer
Answer by Hivemind · Jan 14, 2013 at 05:43 AM
Assuming you are using OnGUI and GUI.Button()
Yea, you will need to create the text object before hand. Then whenever you change that text object, it will update on the button automatically because of the reference.
string btnText = "Some Text";
Rect btnRect;
void OnGUI()
{
GUI.Button(btnRect, btnText);
}