using UnityEngine; using UnityEngine.UI; using System.Collections; public class ChatPanel : PopUpPanel { public Text titleTxt; public ViewStack viewStack; public ChatView chatView; public FriendFindView friendFindView; public Button profileBtn; void Awake() { chatView.titleTxt = titleTxt; } override protected void Remove() { base.Remove (); currentPanel = null; } public static bool IsShown() { return currentPanel != null && currentPanel.gameObject.activeSelf; } private static ChatPanel currentPanel; public static ChatPanel Show() { if (currentPanel != null) { currentPanel.gameObject.SetActive (true); PopUpManager.AddToMainCanvas (currentPanel.gameObject); } else currentPanel = PopUpManager.AddPopUp (Resources.Load ("Prefabs/UI/ChatPanel/ChatPanel"), null, true); currentPanel.Open (); return currentPanel; } public static ChatPanel ShowChat(int friendId) { if (!IsShown()) ChatPanel.Show (); currentPanel.viewStack.viewIndex = 0; currentPanel.chatView.data = friendId; currentPanel.profileBtn.gameObject.SetActive (true); return currentPanel; } public static ChatPanel ShowFindFriend() { if (!IsShown()) ChatPanel.Show (); currentPanel.profileBtn.gameObject.SetActive (false); currentPanel.viewStack.viewIndex = 1; currentPanel.titleTxt.text = Language.GetStr ("ChatPanel", "findPlayer"); return currentPanel; } public static void Hide() { if (currentPanel != null) currentPanel.Close (); } }