public UIWindow CreateWindow(UIcollection window) { switch (window) { case UIcollection.HUD: return(_hudFactory.Create()); case UIcollection.DeBugWindow: return(_deBugFactory.Create()); case UIcollection.Bank: return(_BankFactory.Create()); case UIcollection.ConfirmExit: return(_confirmExitFactory.Create()); default: throw new MissingReferenceException("ooops. no such window in UI Manager"); } }
public void OpenWindow(UIcollection window) { if (_createdWindows.ContainsKey(window)) { var windowPrefab = _createdWindows[window].gameObject; windowPrefab.GetComponent <Canvas>().enabled = true; } else { var windowPrefab = _uiFactory.CreateWindow(window); _createdWindows.Add(window, windowPrefab); } //Hide top Window if it is there if (_menuStack.Count > 0) { if (_createdWindows[window].DisableMenusUnderneath) { foreach (var win in _menuStack) { win.gameObject.GetComponent <Canvas>().enabled = false; if (win.DisableMenusUnderneath) { break; } } } var topCanvas = _createdWindows[window].gameObject.GetComponent <Canvas>(); var prevCanvas = _menuStack.Peek().gameObject.GetComponent <Canvas>(); topCanvas.sortingOrder = prevCanvas.sortingOrder + 1; } //add new window to the Stack _menuStack.Push(_createdWindows[window]); }