- Home /
This question was
closed Dec 04, 2015 at 10:03 PM by
GreenTraveler for the following reason:
The question is answered, right answer was accepted
Question by
GreenTraveler · Dec 04, 2015 at 10:54 AM ·
buttontextlistscrollview
unity 5 change text on UI scrollRect button c#
Greetings..
i have a List of prefabs on a GameManager and a scrollable panel that the code below adds the buttons to the canvas at runtime based on how big the list is.. id like to know how to change the text of each button to the name of the gameobject in each element of the list can anyone give me some pointers please..
public class ButtonList : MonoBehaviour
{
public GameObject prefabButton;
public RectTransform ParentPanel;
void Start ()
{
for(int i = 0; i < GameManager.control.myList.Count; i++)
{
GameObject goButton = (GameObject)Instantiate(prefabButton);
goButton.transform.SetParent(ParentPanel, false);
goButton.transform.localScale = new Vector3(1, 1, 1);
}
}
}
Comment
Follow this Question
Related Questions
A node in a childnode? 1 Answer
GUI & GUI Text Disappear When Publishing 6 Answers
Change Text of GUI Button from Script 2 Answers