GetRoomButton
How do I use Get Room Button
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
67 | private RoomButton GetRoomButton() | 1 |
83 | var button = GetRoomButton(); | 2 |
File name: Lobby.cs
Copy
67 private RoomButton GetRoomButton()
68 {
69 GameObject aGO = (GameObject)Instantiate(roomButtonPrefab, Vector3.zero, Quaternion.identity);
70 aGO.transform.SetParent(grid.transform, false);
71 return aGO.GetComponent
72 }
File name: Lobby.cs
Copy
74 protected override void Update()
75 {
76 base.Update();
77
78 var roomList = NetworkService.GetRoomList();
79
80 // Create more buttons if needed
81 for (int i = 0; i < roomList.Count - roomButtonList.Count; i++)
82 {
83 var button = GetRoomButton();
84 roomButtonList.Add(button);
85 }
86
87 // Update all buttons
88 for (int i = 0; i < roomButtonList.Count; i++)
89 {
90 if (i < roomList.Count)
91 {
92 roomButtonList[i].Init(roomList[i]);
93 roomButtonList[i].gameObject.SetActive(true);
94 }
95 else
96 {
97 roomButtonList[i].gameObject.SetActive(false);
98 }
99 }
100 }
GetRoomButton 129 lượt xem
Gõ tìm kiếm nhanh...