For my game, I need to be able to be able to populate a scroll-able area with buttons. Using the old GUI system, I would just do the following inside a GUILayout scrollview:
foreach (RoomInfo room in PhotonNetwork.GetRoomList())
{
if(GUILayout.Button(room.name))
PhotonNetwork.JoinRoom(room.name);
}
Even though it looked bloody hideous, it got the job done. Now - using the new GUI - I’m wondering how I can reproduce this. Thanks for any help you guys can provide!
ps. I’m definitely a programmer, not an artist or UI designer so forgive my lack of knowledge in this area
public Transform panel_target;//this must have Grid Layout Group
public GameObject mybutton;
GameObject temp;
// Use this for initialization
void Start () {
foreach (RoomInfo room in PhotonNetwork.GetRoomList())
{
temp = (GameObject)Instantiate(mybutton);
temp.transform.parent = panel_target_target;
}
}
There is some really odd behavior when I set the parent of the instantiated to the panel. It should look like this (What I get when I place it not at runtime in the editor)