public virtual void Destroy(Panel_ID panel_ID) { BasePanel panel = GetPanelById(panel_ID); if (panel != null) { panelList.Remove(panel); Destroy(panel.gameObject); } }
public virtual GameObject Create(Panel_ID panel_ID) { if (GetPanelById(panel_ID) != null) { Destroy(panel_ID); } GameObject obj = Tools.CreateGameObject(panelPathDic[panel_ID], tsCanvas); obj.transform.localScale = Vector3.one; panelList.Add(obj.GetComponent <BasePanel>()); return(obj); }
public void PushPanel(Panel_ID panel_ID, object param) { if (panelStack == null) { panelStack = new Stack <BasePanel>(); } if (panelStack.Count > 0) { BasePanel topPanel = panelStack.Peek(); topPanel.OnPause(); } BasePanel panelTemp = GetPanel(panel_ID); panelTemp.OnEnter(param); panelStack.Push(panelTemp); }
public virtual BasePanel GetPanelById(Panel_ID panelId) { BasePanel panel = null; for (int i = 0; i < panelList.Count; i++) { panel = panelList[i]; if (panel != null) { if (panel.GetComponent <BasePanel>().panelID == panelId) { return(panel); } } } return(null); }
private BasePanel GetPanel(Panel_ID id) { if (panelDic == null) { panelDic = new Dictionary <Panel_ID, BasePanel>(); } BasePanel panel; panelDic.TryGetValue(id, out panel); if (panel == null) { string path; panelPathDic.TryGetValue(id, out path); GameObject newPanel = Tools.CreateGameObject(path, tsCanvas); panelDic.Add(id, newPanel.GetComponent <BasePanel>()); return(newPanel.GetComponent <BasePanel>()); } else { return(panel); } }
public void OnAfterDeserialize() { panelID = (Panel_ID)Enum.Parse(typeof(Panel_ID), panelIDString); }