// 打开窗口 public void PushWindow(string name, bool immediately = false, System.Action onComplete = null) { WindowInfo info = null; if (windowsInfo.TryGetValue(name, out info)) { if (info.windowType == WindowType.Window) { ShowMask(0.3f, () => { ClearWindows(); BaseWindow window = LoadWindow(info); AddWindow(window); HideMask(0.3f, null); }); } else { BaseWindow window = LoadWindow(info); AddWindow(window); } } else { Debug.LogError("Can't find window: " + name); } }
public void DestroyWindow(BaseWindow window) { WindowInfo info = window.info; GameObject.DestroyImmediate(window.gameObject); if (info.releaseRes) { Object res = null; if (resMap.TryGetValue(info.name, out res)) { Resources.UnloadAsset(res); } } }
public void PopWindow(bool immediately, System.Action onComplete) { int index = windows.Count - 1; if (index >= 0) { BaseWindow window = windows[index]; windows.Remove(window); window.OnPop(immediately, () => { DestroyWindow(window); SafeCall(onComplete); }); } else { SafeCall(onComplete); } }
private BaseWindow LoadWindow(WindowInfo info) { Object res = null; if (resMap.TryGetValue(info.path, out res) == false) { res = Resources.Load(info.path); resMap.Add(info.name, res); } GameObject windowObj = GameObject.Instantiate(res, Vector3.zero, Quaternion.identity, contentTrans) as GameObject; BaseWindow window = (BaseWindow)GameUtils.GetOrAddComponent(windowObj, info.type); window.info = info; BaseWindowView view = (BaseWindowView)windowObj.GetComponent <BaseWindowView>(); window.SetView(windowObj.GetComponent <BaseWindowView>()); return(window); }
private void AddWindow(BaseWindow window) { this.windows.Add(window); window.OnPush(false, null); }