/// <summary> /// 打开窗口 /// </summary> /// <param name="wndName"></param> /// <param name="bTop"></param> /// <param name="para1"></param> /// <param name="para2"></param> /// <param name="para3"></param> /// <returns></returns> public WindowBase PopUpWnd(string wndName, WindowType type = WindowType.Page, bool bTop = true, params object[] paralist) { WindowBase wnd = FindWndByName <WindowBase>(wndName); if (wnd == null) { System.Type tp = null; if (m_RegisterDic.TryGetValue(wndName, out tp)) { wnd = System.Activator.CreateInstance(tp) as WindowBase; } else { Debug.LogError("找不到窗口对应的脚本,窗口名是:" + wndName); return(null); } GameObject wndObj = ObjectManager.Instance.InstantiateObject(m_UIPrefabPath + wndName + ".prefab", false, false); if (wndObj == null) { Debug.Log("创建窗口Prefab失败:" + wndName); return(null); } if (!m_WindowDic.ContainsKey(wndName)) { m_WindowList.Add(wnd); m_WindowDic.Add(wndName, wnd); } wnd.GameObject = wndObj; wnd.Transform = wndObj.transform; wnd.Name = wndName; wnd.Awake(paralist); if (type == WindowType.Page) { wndObj.transform.SetParent(m_WndRoot, false); } else if (type == WindowType.Dialog) { wndObj.transform.SetParent(m_DialogRoot, false); } else if (type == WindowType.SPContent) { wndObj.transform.SetParent(m_SpcontentRoot, false); } if (bTop) { wndObj.transform.SetAsLastSibling(); } wnd.OnShow(paralist); wnd.currentStates = WindowBase.WindowStates.show; wnd.windowType = type; _currentWindowNameList.Add(wndName); } else { ShowWnd(wndName, bTop, paralist); if (!_currentWindowNameList.Contains(wndName)) { _currentWindowNameList.Add(wndName); } } return(wnd); }