private void OnSyncRoom(byte[] data) { for (int i = 0; i < playerButtonContent.childCount; i++) { Destroy(playerButtonContent.GetChild(i).gameObject); } BaseNetData ndata = Utils.FromBytesJSON <BaseNetData>(data); Room room = ndata.Values["room"].ObjectValue as Room; foreach (Client c in room.Clients) { GameObject mobj = Instantiate(playerButtonPrefab, playerButtonContent); mobj.GetComponent <PlayerButton>().Init(c.Nickname); } }
private void OnGetRooms(byte[] data) { for (int i = 0; i < roomButtonContent.childCount; i++) { Destroy(roomButtonContent.GetChild(i).gameObject); } BaseNetData ndata = Utils.FromBytesJSON <BaseNetData>(data); List <Room> rooms = ndata.Values["rooms"].ObjectValue as List <Room>; foreach (Room r in rooms) { GameObject mobj = Instantiate(roomButtonPrefab, roomButtonContent); mobj.GetComponent <RoomButton>().Init(r.Name); mobj.GetComponent <RoomButton>().ID = r.ID; } }