using System.Collections; using System.Collections.Generic; using UnityEngine; public class GlobalLeaderboard : MonoBehaviour { public Transform leaderboardItemsParent; public LeaderboardItem template; public async void Show(){ AudioManager.instnace.UIPopup(); List leaderboard = await DBmanager.GetLeaderboard(); template.gameObject.SetActive(true); //Clear currentItems for(int i=0; i < leaderboardItemsParent.childCount; i++){ if(leaderboardItemsParent.GetChild(i) == template.transform){ continue; } Destroy(leaderboardItemsParent.GetChild(i).gameObject); } for(int i =0; i < leaderboard.Count; i++){ LeaderboardItem newItem = Instantiate(template.gameObject, leaderboardItemsParent).GetComponent(); newItem.Set(leaderboard[i]); } template.gameObject.SetActive(false); gameObject.SetActive(true); } }