83 lines
2.2 KiB
C#
83 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class FaceDetectUI : UIPanelBase
|
|
{
|
|
public GameObject ItemPrefab;
|
|
|
|
private Dictionary<string, string> itemDetail = new Dictionary<string, string>();
|
|
private Transform _content;
|
|
private List<string> _lockedItem = new List<string>() { "Blond_Hair", "Wearing_Hat" };
|
|
|
|
private void Awake()
|
|
{
|
|
_content = transform.Find("Content/ScrollView/Viewport/Content");
|
|
}
|
|
|
|
public void RefreshData(Dictionary<string, string> 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<PanelItemManager>(out _))
|
|
{
|
|
Destroy(go);
|
|
go = Instantiate(ItemPrefab, _content);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
go = Instantiate(ItemPrefab, _content);
|
|
}
|
|
var mgr = go.GetComponent<PanelItemManager>();
|
|
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");
|
|
}
|
|
}
|