void Start() { DBSysConfig.SysConfig sysConfig = DBSysConfig.Instance.GetConfigById(mSysId); if (sysConfig == null) { return; } if (mIcon != null) { UIBaseWindow mainmapWindow = UIManager.Instance.GetWindow("UIMainmapWindow"); if (mainmapWindow != null) { mIcon.sprite = mainmapWindow.LoadSprite(sysConfig.BtnSprite); } } if (mName != null) { mName.text = sysConfig.BtnText; } UpdateState(); if (mButton != null) { mButton.onClick.AddListener(OnClickButton); } ClientEventMgr.Instance.SubscribeClientEvent((int)ClientEvent.CE_SYS_CONFIG_INIT, OnSysConfigInit); ClientEventMgr.Instance.SubscribeClientEvent((int)ClientEvent.CE_SYS_OPEN, OnSysOpen); }
private UIBaseWindow GetWindow(string windowName) { UIBaseWindow window = null; windowDic.TryGetValue(windowName, out window); return(window); }
public void RecordMetric(UIBaseWindow window, string name, object metric) { if (_windowToNode == null) { return; } if (!_windowToNode.TryGetValue(window, out UIDebugNode? node)) { node = new UIDebugNode(window); _windowToNode.Add(window, node); UIBaseWindow?windowParent = window.Parent; if (windowParent != null) { bool found = _windowToNode.TryGetValue(windowParent, out UIDebugNode? parentNode); Debug.Assert(found && parentNode != null); parentNode.SubNodes.Add(node); } } bool present = node.Metrics.ContainsKey(name); Debug.Assert(!present, "Window is present twice in hierarchy (by reference)."); if (present) { return; } node.Metrics.Add(name, metric); }
private void AdjustBaseWindowDepth(UIBaseWindow baseWindow) { UIWindowType windowType = baseWindow.windowData.windowType; int needDepth = 1; if (windowType == UIWindowType.Normal) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UINormalWindowRoot.gameObject, false) + 1, normalWindowDepth, int.MaxValue); Debug.Log("[UIWindowType.Normal] maxDepth is " + needDepth + baseWindow.GetID); } else if (windowType == UIWindowType.PopUp) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UIPopUpWindowRoot.gameObject) + 1, popUpWindowDepth, int.MaxValue); Debug.Log("[UIWindowType.PopUp] maxDepth is " + needDepth); } else if (windowType == UIWindowType.Fixed) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UIFixedWidowRoot.gameObject) + 1, fixedWindowDepth, int.MaxValue); Debug.Log("[UIWindowType.Fixed] max depth is " + needDepth); } if (baseWindow.MinDepth != needDepth) { GameUtility.SetTargetMinPanel(baseWindow.gameObject, needDepth); } baseWindow.MinDepth = needDepth; }
protected override UIBaseWindow ReadyToShowBaseWindow(WindowID id) { // 检测控制权限 if (!this.IsWindowInControl(id)) { Debug.Log("UIManager has no control power of " + id.ToString()); return(null); } if (ShownWindows.ContainsKey(id)) { return(null); } // 隐藏callWindowId指向窗口 /*if(showData != null) * HideWindow(showData.callWindowId, null);*/ UIBaseWindow baseWindow = GetGameWindow(id); bool newAdded = false; if (!baseWindow) { newAdded = true; // 窗口不存在从内存进行加载 if (AppConst.windowPrefabPath.ContainsKey(id)) { GameObject prefab = ResourcesMgr.Instance.LoadResource <GameObject>(ResourceType.RESOURCE_UI, AppConst.windowPrefabPath[id]); if (prefab != null) { GameObject uiObject = (GameObject)GameObject.Instantiate(prefab); Util.SetActive(uiObject, true); baseWindow = uiObject.GetComponent <UIBaseWindow>(); Util.AddChildToTarget(UINormalWindowRoot, baseWindow.transform); AllWindows[id] = baseWindow; } } } if (baseWindow == null) { Debug.LogError("[window instance is null.]" + id.ToString()); return(null); } if (newAdded) { baseWindow.ResetWindow(); } //// 导航系统数据更新 //RefreshBackSequenceData(baseWindow); //// 调整层级depth //AdjustBaseWindowDepth(baseWindow); //// 添加背景Collider //AddColliderBgForWindow(baseWindow); return(baseWindow); }
/// <summary> /// 判断控件是否可见 /// </summary> /// <param name="widget"></param> /// <returns></returns> public bool IsWidgetVisible(GameObject widget) { if (widget == null) { return(false); } bool widget_is_visible = false; RectTransform rect_trans = widget.GetComponent <RectTransform>(); if (rect_trans != null) { Vector3[] world_corner = new Vector3[4]; rect_trans.GetWorldCorners(world_corner); Camera current_cam = UIMainCtrl.MainCam; if (current_cam != null) { Vector3 center = (world_corner[0] + world_corner[2]) * 0.5f; var screen_pos = current_cam.WorldToScreenPoint(center); if (pointerData == null) { pointerData = new PointerEventData(EventSystem.current); } bool hasGuideWindow = false; for (int i = m_IgnoreRaycastGameObjects.Count - 1; i >= 0; i--) { if (m_IgnoreRaycastGameObjects[i] == null) { m_IgnoreRaycastGameObjects.Remove(m_IgnoreRaycastGameObjects[i]); continue; } if (m_IgnoreRaycastGameObjects[i].name == "UIGuideWindow") { hasGuideWindow = true; break; } } if (!hasGuideWindow) { UIBaseWindow guidewnd = UIManager.Instance.GetWindow("UIGuideWindow"); if (guidewnd != null) { m_IgnoreRaycastGameObjects.Add(guidewnd.mUIObject); } } var hit_obj = UGUIMath.GetRaycastObj(screen_pos, pointerData, m_IgnoreRaycastGameObjects, true); if (hit_obj != null && UGUIMath.ContainWidget(widget, hit_obj)) { widget_is_visible = true; } } } return(widget.activeInHierarchy && widget_is_visible); }
public UIDebugNode?GetMetricsForWindow(UIBaseWindow window) { if (_windowToNode == null) { return(null); } _windowToNode.TryGetValue(window, out UIDebugNode? node); return(node); }
public override void AddChild(UIBaseWindow child) { if (child == null) { return; } base.AddChild(child); child.AttachedToController(this); }
public void ShowWindow(string windowName, EventParam param, Action OnComplete) { UIBaseWindow window = LoadWindow(windowName); if (null != window) { window.ShowWindow(param, OnComplete); } }
private void HandleWindowRenderOrder() { windowLst.Sort((lhs, rhs) => { return(lhs.PageSlib.CompareTo(rhs.PageSlib)); }); for (int index = 0; index < windowLst.Count; ++index) { UIBaseWindow window = windowLst[index]; window.transform.SetSiblingIndex(index); } }
public void AddWindow(UIBaseWindow window) { if (!windowsDict.ContainsKey(window.Id)) { var cloned = Instantiate(window, windowsRoot); cloned.Init(); windowsDict.Add(cloned.Id, cloned); OnWindowAdded(cloned); } }
public bool IsWindowOpen(string windowName) { UIBaseWindow window = null; if (windowDic.TryGetValue(windowName, out window)) { return(window.IsShow); } return(false); }
public virtual T GetGameWindowScript <T>(WindowID id) where T : UIBaseWindow { UIBaseWindow baseWindow = GetGameWindow(id); if (baseWindow != null) { return((T)baseWindow); } return((T)((object)null)); }
/// <summary> /// 显示界面,方面在现实之前做其他操作 /// </summary> protected virtual void RealShowWindow(UIBaseWindow baseWindow, WindowID id) { baseWindow.ShowWindow(); shownWindows[id] = baseWindow; if (baseWindow.windowData.windowType == UIWindowType.Normal) { // 改变当前显示Normal窗口 lastShownNormalWindow = curShownNormalWindow; curShownNormalWindow = baseWindow; } }
public override void RemoveChild(UIBaseWindow win, bool evict = true) { if (Children == null) { return; } if (evict) { Children.Remove(win); } }
private bool ReturnWindowManager(UIBaseWindow baseWindow) { // 退出当前界面子界面 UIManagerBase baseWindowManager = baseWindow.GetWindowManager; bool isValid = false; if (baseWindowManager != null) { isValid = baseWindowManager.ReturnWindow(); } return(isValid); }
public void RemoveWindow(UIBaseWindow window) { if (!window) { return; } var windowId = window.Id; windowsDict.Remove(windowId); OnWindowRemoved?.Invoke(windowId); Destroy(window.gameObject); }
public void AddWindow(UIBaseWindow window) { if (!window) { return; } if (!windowsDict.ContainsKey(window.Id)) { windowsDict[window.Id] = Instantiate(window, windowsRoot); OnWindowAdded?.Invoke(window); } }
/// <summary> /// 清空所有界面 /// </summary> public virtual void ClearAllWindow() { if (allWindows != null) { foreach (KeyValuePair <WindowID, UIBaseWindow> window in allWindows) { UIBaseWindow baseWindow = window.Value; baseWindow.DestroyWindow(); } allWindows.Clear(); shownWindows.Clear(); backSequence.Clear(); } }
private void CheckBackSequenceData(UIBaseWindow baseWindow) { // 如果当前存在BackSequence数据 // 1.栈顶界面不是当前要显示的界面需要清空BackSequence(导航被重置) // 2.栈顶界面是当前显示界面,如果类型为(NeedBack)则需要显示所有backShowTargets界面 WindowData windowData = baseWindow.windowData; if (baseWindow.RefreshBackSeqData) { if (backSequence.Count > 0) { BackWindowSequenceData backData = backSequence.Peek(); if (backData.hideTargetWindow != null) { // 栈顶不是即将显示界面(导航序列被打断) if (backData.hideTargetWindow.GetID != baseWindow.GetID) { Debug.Log("[**Need to clear all back window sequence data**]."); Debug.Log("[hide target window and show window id is " + backData.hideTargetWindow.GetID + " != " + baseWindow.GetID); backSequence.Clear(); } else { // NeedBack类型要将backShowTargets界面显示 if (windowData.showMode == UIWindowShowMode.NeedBack && backData.backShowTargets != null) { for (int i = 0; i < backData.backShowTargets.Count; i++) { WindowID backId = backData.backShowTargets[i]; // 保证最上面为currentShownWindow if (i == backData.backShowTargets.Count - 1) { Debug.Log("change currentShownNormalWindow : " + backId); // 改变当前活跃Normal窗口 this.lastShownNormalWindow = this.curShownNormalWindow; this.curShownNormalWindow = GetGameWindow(backId); } ShowWindowForBack(backId); } } } } else { Debug.LogError("Back data hide target window is null!"); } } } }
public override void ShowWindow(WindowID id) { Init(); UIBaseWindow baseWindow = ReadyToShowBaseWindow(id); if (baseWindow != null) { RealShowWindow(baseWindow, id); // 是否清空当前导航信息(回到主菜单) if (baseWindow.windowData.isStartWindow) { ClearBackSequence(); } } }
// 直接打开窗口 protected void ShowWindowForBack(WindowID id) { // 检测控制权限 if (!this.IsWindowInControl(id)) { Debug.Log("UIManager has no control power of " + id.ToString()); return; } if (shownWindows.ContainsKey(id)) { return; } UIBaseWindow baseWindow = GetGameWindow(id); baseWindow.ShowWindow(); shownWindows[baseWindow.GetID] = baseWindow; }
/// <summary> /// 窗口背景碰撞体处理 /// </summary> private void AddColliderBgForWindow(UIBaseWindow baseWindow) { UIWindowColliderMode colliderMode = baseWindow.windowData.colliderMode; if (colliderMode == UIWindowColliderMode.None) { return; } if (colliderMode == UIWindowColliderMode.Normal) { GameUtility.AddColliderBgToTarget(baseWindow.gameObject, "common_mask_black", maskAtlas, true); } if (colliderMode == UIWindowColliderMode.WithBg) { GameUtility.AddColliderBgToTarget(baseWindow.gameObject, "common_mask_black", maskAtlas, false); } }
public void hideWindow(string windowName, Action OnComplete) { UIBaseWindow window = GetWindow(windowName); if (null == window) { return; } window.HideWindow(() => { windowDic.Remove(windowName); windowLst.Remove(window); if (null != OnComplete) { OnComplete(); } }); }
public override void ShowWindow(WindowID id, ShowWindowData data = null) { UIBaseWindow baseWindow = ReadyToShowBaseWindow(id, data); if (baseWindow != null) { RealShowWindow(baseWindow, id); // 是否清空当前导航信息(回到主菜单) if (baseWindow.windowData.isStartWindow) { Debug.Log("[Enter the start window, reset the backSequenceData for the navigation system.]"); ClearBackSequence(); } if (data != null && data.forceClearBackSeqData) { ClearBackSequence(); } } }
/// <summary> /// 检查新手指引 /// </summary> /// <param name="deltaTime"></param> void CheckGuides(float deltaTime) { // 提审状态开启时,不显示新手引导 if (mPause || AuditManager.Instance.Open) { return; } // 更新当前的指引步骤 if (m_IsPlayingGuideStep) { if (!m_PlayingGuideStep.TargetTrigger.Finished && !m_PlayingGuideStep.CheckGuideCondition()) { ResetGuideStep(m_PlayingGuideStep); UIBaseWindow guidewnd = UIManager.Instance.GetWindow("UIGuideWindow"); if (guidewnd != null) { guidewnd.Close(); } } else if (m_PlayingGuideStep.TargetTrigger.IsAchieve())// 当前步骤已经完成 { FinishGuideStep(m_PlayingGuideStep); } else if (PlayingGuideStep.IsForcible)// 当前的强制指引未完成,不开启新的指引 { return; } } if (m_Dirty) { ResetListener(); } if (!CheckGuideDict(m_ForceStartStepDict)) { CheckGuideDict(m_ListeningStepDict); } }
private void InitRootWindowConfig() { windowsParent = Utils.FindChild(uiRoot, "Canvas/windows_parent"); if (null == windowsParent) { Logger.LogError("find windows parent node failed!!! uiroot name = " + uiRoot.name); } UIBaseWindow[] windows = windowsParent.GetComponentsInChildren <UIBaseWindow>(true); for (int index = 0; index < windows.Length; ++index) { UIBaseWindow window = windows[index]; windowDic[window.name] = window; windowLst.Add(window); if (window.IsDefaultOpen) { window.ShowWindow(); } } }
private UIBaseWindow LoadWindow(string windowName) { UIBaseWindow window = GetWindow(windowName); if (null == window) { GameObject uiObj = LoadGameObject(windowName + ".ui"); if (null == uiObj) { Logger.LogError("load ui object failed!!! name = " + windowName); return(null); } window = uiObj.GetComponent <UIBaseWindow>(); windowDic[windowName] = window; windowLst.Add(window); if (null != windowsParent) { uiObj.SetParent(windowsParent); RectTransform rect = uiObj.transform as RectTransform; if (null != rect) { rect.offsetMax = Vector2.zero; rect.offsetMin = Vector2.zero; } } else { Debug.LogError("the window parent node is null"); } HandleWindowRenderOrder(); } return(window); }
public override void AddChild(UIBaseWindow child) { Children ??= new List <UIBaseWindow>(); Children.Add(child); }
public override void RemoveChild(UIBaseWindow win, bool evict = true) { base.RemoveChild(win, evict); win.DetachedFromController(this); InvalidateInputFocus(); }