I'm just wondering how I'd go about handling each gameobject. UITextList only uses a single label because you can only interact with the label itself (to scroll). However, if I wanted a button beside each listing I'd need to create a new button object for each listing unless I'm missing something.
One way I'm thinking of doing it is, on start, create (and set inactive) X gameobjects with a button component (where X is the number of servers the browser can display) and store it in an array. Then, whenever the server list is updated (which returns an array), set active the matching index in the button array. All other buttons would be set inactive.
Somewhat pseudocode to help visualize what I just said:
private CustomizedUIButton[] buttons;
private void Start()
{
buttons
= new CustomizedUIButton
[maxServersDisplay
]; for (int i = 0; i < buttons.Length; i++) buttons[i] = MakeAButtonAtTheProperLocation();
RefreshServers();
}
public void RefreshServers()
{
SetAllInactive(buttons);
Server[] servers = GetServers();
for (int i = 0; i < servers.Length; i++) buttons[i].SetActive(true);
}
Am I on the right track here or am I completely off the mark? It just seems wrong to make ~50 or so individual button objects, even if they are mostly inactive.