- Home /
Question by
spinnerbox · Dec 16, 2015 at 12:08 PM ·
unity 5buttonsuser interfacelabels
Access text label inside a button - Unity 5.1.4
How to change button's label text? I tried these codes:
playBtnLabel = playBtn.gameObject.GetComponent<Text>();
// playBtnLabel is null and
playBtnLabel = playBtn.GetComponent<Text>();
// again playBtnLabel is null
What do i do wrong?
Comment
Best Answer
Answer by spinnerbox · Dec 16, 2015 at 12:15 PM
Try
playBtn.gameObject.GetComponentInChildren<Text>();
It works!
Your answer
Follow this Question
Related Questions
Change properties of a button by pressing another button in Unity 1 Answer
How to load instances of a prefab to an array c# 2 Answers
Instanstiating activated and deactivated buttons on every update 2 Answers
UI Button OnClick Sensitivity for High DPI Devices 5 Answers
How can i spawn floating labels around button on click? 1 Answer