using System.Collections; using System.Collections.Generic; using UnityEngine; public class FaceDetectUI : UIPanelBase { public GameObject ItemPrefab; private Dictionary itemDetail = new Dictionary(); private Transform _content; private List _lockedItem = new List() { "Blond_Hair", "Wearing_Hat" }; private void Awake() { _content = transform.Find("Content/ScrollView/Viewport/Content"); } public void RefreshData(Dictionary items) { int index = 0; int count = _content.transform.childCount; for (int i = 0; i < count; i++) { if (_content.transform.GetChild(i).gameObject.activeSelf) { _content.transform.GetChild(i).gameObject.SetActive(false); } } if (count < items.Count) { for (int i = count; i < items.Count; i++) { Instantiate(ItemPrefab, _content); } } foreach (var item in items) { if (item.Key.Equals("Bald")) continue; GameObject go; if (index < count) { go = _content.transform.GetChild(index).gameObject; if (!go.TryGetComponent(out _)) { Destroy(go); go = Instantiate(ItemPrefab, _content); } } else { go = Instantiate(ItemPrefab, _content); } var mgr = go.GetComponent(); mgr.Title.text = item.Key; mgr.Description.text = item.Value; go.transform.gameObject.SetActive(true); go.transform.SetSiblingIndex(index); if (_lockedItem.Contains(item.Key)) { mgr.Lock(); } else { mgr.UnLock(); } index++; } } public void OnBackBtnClicked() { UIManager.Instance.CloseCurrent(); LoadingManager.Instance.Load("Boot"); } }