using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; public class MailPanel : PopUpPanel { public Text title; public Transform listContainer; public MailItem itemPrefab; void Awake () { title.text = Language.GetStr("MailPanel", "title"); ListHelper.HideAll (listContainer); itemPrefab.mailPanel = this; } protected override void Shown () { FillMsg (ChatManager.GetInstance ().GetMailMsgList()); ChatManager.GetInstance ().MailMsgGot.AddListener (OnMailMsgGot); } private void FillMsg(List list) { ListHelper.FillList (listContainer, list, itemPrefab, ChatManager.MAX_MAIL); } private void OnMailMsgGot(ChatMsg chatMsg) { ListHelper.AddToList (listContainer, chatMsg, itemPrefab, ChatManager.MAX_MAIL); } override protected void Remove() { base.Remove (); currentPanel = null; ChatManager.GetInstance ().MailMsgGot.RemoveListener (OnMailMsgGot); } private static MailPanel currentPanel; public static MailPanel Show() { if (currentPanel != null) { currentPanel.gameObject.SetActive (true); PopUpManager.AddToMainCanvas (currentPanel.gameObject); } else currentPanel = PopUpManager.AddPopUp (Resources.Load ("Prefabs/UI/MailPanel/MailPanel"), null, true); currentPanel.Open (); return currentPanel; } }