public void RefreshUIByType(UIWndType type) { if (uiDict == null) { uiDict = new Dictionary <UIWndType, BaseWnd>(); } if (!uiDict.ContainsKey(type)) { GameObject instanceWnd = GameObject.Instantiate(Resources.Load(uiPathDict[type]), CanvasTransform) as GameObject; uiDict.Add(type, instanceWnd.GetComponent <BaseWnd>()); } uiDict[type].RefreshUI(); }
/// <summary> /// 解析UIWndTypeJson /// </summary> private void ParseUIWndTypeJson() { uiPathDict = new Dictionary <UIWndType, string>(); TextAsset textAsset = Resources.Load <TextAsset>("UIWnd"); JsonData jsonData = JsonMapper.ToObject(textAsset.text); foreach (JsonData item in jsonData) { string typeName = item["wndType"].ToString(); UIWndType wndType = (UIWndType)System.Enum.Parse(typeof(UIWndType), typeName); string path = item["path"].ToString(); uiPathDict.Add(wndType, path); } }
public void PushWnd(UIWndType type) { if (wndStack == null) { wndStack = new Stack <BaseWnd>(); } BaseWnd newWnd = GetWnd(type); //Debug.Log(uiDict.Count); if (type == UIWndType.Battle) { GameManager.instance.GetBattle(); } newWnd.Init(); newWnd.OnShow(); wndStack.Push(newWnd); }
public BaseWnd GetWnd(UIWndType type) { if (uiDict == null) { uiDict = new Dictionary <UIWndType, BaseWnd>(); } BaseWnd wnd; uiDict.TryGetValue(type, out wnd); if (wnd == null) { GameObject instanceWnd = GameObject.Instantiate(Resources.Load(uiPathDict[type]), CanvasTransform) as GameObject; uiDict.Add(type, instanceWnd.GetComponent <BaseWnd>()); } return(uiDict[type]); }