using UnityEngine; using System.Collections; using UnityEngine.UI; using System.Collections.Generic; public class AucationSelfRecordPanel : MonoBehaviour { public static AucationSelfRecordPanel Instance; private void Awake() { Instance = this; } private void OnDestroy() { Instance = null; } public GameObject itemPrefab; public Transform itemPrefabParent; public GameObject noInfoIcon; private void OnEnable() { AskForInfo(); } public void AskForInfo() { CG_REQ_SNATCH_BET_ITEMS req = (CG_REQ_SNATCH_BET_ITEMS)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SNATCH_BET_ITEMS); req.SetType(3); req.SendPacket(); } private List itemPrefabList = new List(); public void CreatePrefab(GC_RET_SNATCH_HISTORY_RET_ITEMS packet) { ClearAllPrefabAndList(); if(packet.historyItemInfoCount <= 0) { if(!noInfoIcon.activeInHierarchy) { noInfoIcon.SetActive(true); return; } }else { if (noInfoIcon.activeInHierarchy) { noInfoIcon.SetActive(false); } } for (int index = 0; index < packet.historyItemInfoCount; index++) { GameObject item = GameObject.Instantiate(itemPrefab); item.transform.SetParent(itemPrefabParent); item.transform.localPosition = Vector3.zero; item.transform.localRotation = Quaternion.Euler(Vector3.zero); item.transform.localScale = Vector3.one; item.GetComponent().InitItem(packet.GetHistoryItemInfo(index).Tm, packet.GetHistoryItemInfo(index).ItemIndexId, packet.GetHistoryItemInfo(index).Betnum, index); itemPrefabList.Add(item); } } public void ClearAllPrefabAndList() { for (int index = 0; index < itemPrefabList.Count; index++) { GameObject.Destroy(itemPrefabList[index]); } itemPrefabList.Clear(); } public void OnCloseBtnClick() { UIManager.CloseUI(UIInfo.AucationSelfRecordPanel); } }