using UnityEngine; using System.Collections; using UnityEngine.UI; using System.Collections.Generic; public class AucationNewResultPanel : MonoBehaviour { public GameObject itemPrefab; public Transform itemPrefabParent; public GameObject noInfoIcon; public static AucationNewResultPanel Instance; private void Awake() { Instance = this; } private void OnDestroy() { Instance = null; } 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(2); req.SendPacket(); } private List itemPrefabList = new List(); public void GetAllRecoedInfo(GC_RET_SNATCH_NEW_OEPN_RET_ITEM packet) { ClearAllPrefabAndList(); if(packet.newOpenItemInfoCount <= 0) { if(!noInfoIcon.activeInHierarchy) { noInfoIcon.SetActive(true); return; } }else { if (noInfoIcon.activeInHierarchy) { noInfoIcon.SetActive(false); } } for(int index = packet.newOpenItemInfoCount - 1; index >= 0; 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.GetNewOpenItemInfo(index).Tm, packet.GetNewOpenItemInfo(index).ItemIndexId, packet.GetNewOpenItemInfo(index).WinnerNames, packet.GetNewOpenItemInfo(index).WinnerBetNum, index); itemPrefabList.Add(item); } } public void ClearAllPrefabAndList() { for(int index = 0; index < itemPrefabList.Count; index++) { GameObject.Destroy(itemPrefabList[index]); } itemPrefabList.Clear(); } }