/// <summary> /// Add a row to the Message list. /// </summary> public void AddRowForMessage(string title, string objectId, TableRow.SelectedHandler callback) { if (currentMessageRowCount == MAX_MESSAGE_ROW_COUNT) { //remove the first message when MAX_MESSAGE_ROW_COUNT is reached. RemoveChild(messageList.transform); currentMessageRowCount--; } currentMessageRowCount++; AddRowToTable(messageList.transform, messageRowPrefab, title, objectId, callback); }
/// <summary> /// Add a row to the Player list. /// </summary> public void AddRowForPlayer(string title, string objectId, TableRow.SelectedHandler callback) { AddRowToTable(playerList.transform, playerRowPrefab, title, objectId, callback); }
/// <summary> /// Add a row to the Room list. /// </summary> public void AddRowForRoom(string title, string objectId, TableRow.SelectedHandler callback) { AddRowToTable(roomList.transform, roomRowPrefab, title, objectId, callback); }
// Helper methods void AddRowToTable(Transform table, GameObject rowPrefab, string title, string objectId, TableRow.SelectedHandler callback) { GameObject newRow = Instantiate(rowPrefab, table); TableRow tableRow = newRow.GetComponent <TableRow>(); tableRow.OnSelected += callback; tableRow.SetTitle(title); tableRow.SetObjectId(objectId); }