123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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<ChatMsg> list)
- {
- ListHelper.FillList<ChatMsg> (listContainer, list, itemPrefab, ChatManager.MAX_MAIL);
- }
- private void OnMailMsgGot(ChatMsg chatMsg)
- {
- ListHelper.AddToList<ChatMsg> (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<MailPanel> (Resources.Load<GameObject> ("Prefabs/UI/MailPanel/MailPanel"), null, true);
- currentPanel.Open ();
- return currentPanel;
- }
- }
|