//反序列化 public void OnAfterDeserialize() { Debug.Log(panelTypeString); UiPaneltype type = (UiPaneltype)System.Enum.Parse(typeof(UiPaneltype), panelTypeString); panelType = type; }
/// <summary> /// 根据面板得到实例化的面板 /// </summary> public BasePanel GetPanel(UiPaneltype panelType) { if (panelDate == null)//paneldate是否为空 { panelDate = new Dictionary <UiPaneltype, BasePanel>(); } //BasePanel basePanel; //panelDate.TryGetValue(panelType, out basePanel); BasePanel panel = panelDate.TryGet(panelType); if (panel == null) {//如果找不到找不到,就找planePathdt //string path; //planePathDict.TryGetValue(panelType, out path); string path = planePathDict.TryGet(panelType); GameObject instantpanel = (GameObject)GameObject.Instantiate(Resources.Load(path)); instantpanel.transform.SetParent(CanvasTransfrom, false); panelDate.Add(panelType, instantpanel.GetComponent <BasePanel>()); return(instantpanel.GetComponent <BasePanel>()); } else { return(panel); } }
/// <summary> /// 把某个界面入栈,把某个界面显示出来 /// </summary> public void pushPanel(UiPaneltype uiPaneltype) { if (panelStack == null) { panelStack = new Stack <BasePanel>(); } //判断一下栈里是否有页面? if (panelStack.Count > 0) { BasePanel Toppanel = panelStack.Peek(); Toppanel.OnPause(); } BasePanel Panel = GetPanel(uiPaneltype); //得到面板 panelStack.Push(Panel); //把面板加载到栈 Panel.OnEnter(); //调用OnEnter方法 }
public void OnPushPanel(string paneltypestring) { UiPaneltype paneltype = (UiPaneltype)System.Enum.Parse(typeof(UiPaneltype), paneltypestring); UIManager.Instance.pushPanel(paneltype); }