private async Task <UIViewBase> CreateUIView(SO_UIViewConfig config) { var handle = Addressables.InstantiateAsync(config.Address); await handle.Task; if (handle.Status == AsyncOperationStatus.Succeeded) { handle.Result.transform.CleanName(); UIViewBase view = handle.Result.GetComponent <UIViewBase>(); return(view); } Debug.LogError($"加载{config.assetName}失败"); return(null); }
private UIViewBase GetView(string dlgName) { if (string.IsNullOrEmpty(dlgName)) { return(null); } UIViewBase view = null; dicView.TryGetValue(dlgName, out view); if (view == null) { view = RegisterDlgScripte(dlgName); } return(view); }
/// <summary> /// 关闭UI /// </summary> /// <param name="id"></param> /// <returns></returns> protected void CloseUI(UIID id) { if (!_register.ContainsKey(id)) { return; } if (!_register[id].OnClose()) { return; } _register[id].isOpen = false; UIViewBase closeView = _register[id].GetView(); closeView.SetView(false); --layerOrder[closeView.config.Layer]; }
private void UpdateContentTemplate() { Column mainColumn = this.MainColumn as Column; if (mainColumn == null) { return; } DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); UIViewBase uiViewBase = null; if (dataGridContext != null) { DataGridControl dataGridControl = dataGridContext.DataGridControl; if (dataGridControl != null) { uiViewBase = dataGridControl.GetView() as UIViewBase; } } if (uiViewBase != null) { if (uiViewBase.ScrollTipContentTemplate != null) { this.ContentTemplate = uiViewBase.ScrollTipContentTemplate; } else { this.ContentTemplateSelector = uiViewBase.ScrollTipContentTemplateSelector; } } if ((this.ContentTemplate == null) && (this.ContentTemplateSelector == null)) { if (mainColumn.CellContentTemplate != null) { this.ContentTemplate = mainColumn.CellContentTemplate; } else { this.ContentTemplateSelector = mainColumn.CellContentTemplateSelector; } } }
/// <summary> /// 关闭View /// </summary> /// <param name="name"></param> public void CloseView(string name, bool wakeUp = true) { if (m_UIDataMap.ContainsKey(name)) { UIData m_UIData = m_UIDataMap[name]; m_UIData.gameObject.SetActive(false); UIViewBase baseView = m_UIDataMap[name].gameObject.GetComponent <UIViewBase>(); if (baseView != null) { baseView.OnClose(); } switch (m_UIData.viewStyle) { case UIViewStyle.Page: case UIViewStyle.Window: m_StackPage.Remove(m_UIData); if (m_StackPage.Count > 0) { if (wakeUp) { ActiveView(m_StackPage[m_StackPage.Count - 1], m_UIData.viewStyle == UIViewStyle.Page); } m_topPage = m_StackPage[m_StackPage.Count - 1].name; m_topViewData = m_StackPage[m_StackPage.Count - 1]; } else { m_topPage = null; m_topViewData = null; } break; case UIViewStyle.OverView: m_StackOverView.Remove(m_UIData); if (m_StackOverView.Count > 0) { m_topOverView = m_StackOverView[m_StackOverView.Count - 1].name; } else { m_topOverView = null; } break; } m_UIData.hidenOverView.Clear(); } }
/// <summary> /// 打开一个UI /// </summary> /// <param name="id"></param> /// <returns></returns> protected UIConfig OpenUI(UIID id) { IUICtrl ctrl = _register[id]; UIConfig uiJson = JsonMgr.GetSingleton().GetUIConfigByID((int)id); if (uiJson == null) { return(null); } UIViewBase vb = ctrl.GetView(); if (vb == null) { GameObject uigo = GameObject.Instantiate(ResourceMgr.Instance.LoadResource(uiJson.Resid) as GameObject); if (uigo == null) { throw new System.Exception("加载UI资源出错 -------- " + uiJson.Resid); } vb = uigo.GetComponent <UIViewBase>(); ctrl.SetView(vb); ctrl.OnInit(); vb.AddComponent(uiJson); } vb.SetOrder(++layerOrder[uiJson.Layer]); if (!ctrl.IsOpen()) { vb.SetView(true); ctrl.OnOpen(); } if (!openList.Contains(id)) { if ((uiJson.Layer.Equals("UI1") || uiJson.Layer.Equals("Default"))) { Debug.LogFormat("Add into OpenList {0}", id); openList.Add(id); } } else { //换到队尾 openList.Remove(id); openList.Add(id); } return(uiJson); }
/// <summary> /// Lua代码使用,注册一个UI /// </summary> /// <param name="id"></param> /// <returns></returns> public UIViewBase Register(string id) { UIViewBase viewBase = null; if (m_AllWindows.TryGetValue(id, out viewBase)) { Debug.LogError("重复注册的UI的ID = " + id); return(viewBase); } else { viewBase = new UIViewBase(); viewBase.ID = id; m_AllWindows[id] = viewBase; return(viewBase); } }
private void ShowDropMark(Point mousePosition, DropMarkAlignment defaultAlignment, bool forceDefaultAlignment) { if (m_dropMarkAdorner == null) { DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); DataGridControl grid = (dataGridContext != null) ? dataGridContext.DataGridControl : null; Pen pen = UIViewBase.GetDropMarkPen(this); if ((pen == null) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; pen = uiViewBase.DefaultDropMarkPen; } DropMarkOrientation orientation = Nequeo.Wpf.DataGrid.Views.UIViewBase.GetDropMarkOrientation(this); if ((orientation == DropMarkOrientation.Default) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; orientation = uiViewBase.DefaultDropMarkOrientation; } m_dropMarkAdorner = new DropMarkAdorner(this, pen, orientation); AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { adornerLayer.Add(m_dropMarkAdorner); } } if (forceDefaultAlignment) { m_dropMarkAdorner.ForceAlignment(defaultAlignment); } else { m_dropMarkAdorner.UpdateAlignment(mousePosition); } }
static int set_ViewBase(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIItem obj = (UIItem)o; UIViewBase arg0 = (UIViewBase)ToLua.CheckUnityObject(L, 2, typeof(UIViewBase)); obj.ViewBase = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index ViewBase on a nil value" : e.Message)); } }
static int get_ViewBase(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIItem obj = (UIItem)o; UIViewBase ret = obj.ViewBase; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index ViewBase on a nil value" : e.Message)); } }
public void OpenView(UIViewId viewId, object param = null, System.Action hdlOnSuccess = null) { Logger.LogInfo("打开界面: " + viewId.ToString()); ViewConfigInfo configInfo = null; if (!mViewConfig.TryGetValue(viewId, out configInfo)) { Logger.LogError("UIManager open not registered view:" + viewId.ToString()); return; } if (mOpendViewDic.ContainsKey(viewId)) { Logger.LogError("UIManager open opened view,viewId:" + viewId.ToString()); return; } if (mOpeningViewDic.ContainsKey(viewId)) { mOpeningViewDic [viewId] = param; return; } mOpeningViewDic.Add(viewId, param); GameMain.Instance.ResMgr.LoadResourceAsync(this, configInfo.prefabName, typeof(GameObject), delegate(Object prefab) { if (mWaitCloseingSet.Contains(viewId)) { GameMain.Instance.ResMgr.UnloadResource(configInfo.prefabName, typeof(GameObject)); mWaitCloseingSet.Remove(viewId); } else { UIViewBase viewBase = System.Activator.CreateInstance(mViewConfig[viewId].viewType) as UIViewBase; viewBase.Open(viewId, prefab as GameObject, mViewRoot, mOpeningViewDic[viewId]); mOpendViewDic.Add(viewId, viewBase); if (null != hdlOnSuccess) { hdlOnSuccess.Invoke(); } } mOpeningViewDic.Remove(viewId); }, delegate(string errorCode) { Logger.LogError("UIManager load " + configInfo.prefabName + " error, code:" + errorCode); }); }
public void HideView(UIViewBase view) { if (view == null) { return; } if (view.LayerController != null) { viewList.Remove(view); view.LayerController.Popup(view); SchemeViewCache(view); UpdateViewHideState(); } else { Debug.LogError($"关闭界面错误: {view.Config.viewName}, 没有层级"); } }
//version79.3 private static UIViewBase PreparePrefab(WindowID id, object asset) { //加载成功 GameObject prefab = asset as GameObject; if (prefab != null) { GameObject uiObject = GameObject.Instantiate(prefab); uiObject.SetActive(true); //获取UIViewBase脚本或者添加 UIViewBase uiView = uiObject.GetComponent <UIViewBase>(); if (uiView == null) { WindowID UIID = (WindowID)Enum.Parse(typeof(WindowID), id.ToString()); string UIViewScriptName = UIID.ToString() + UIGlobalDefine.ViewScriptSuffix; Debug.LogWarning("Prefab没有添加脚本!!!!" + UIViewScriptName); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { Type t = assembly.GetType(string.Format("{0}.{1}", UIGlobalDefine.UINameSPace, UIViewScriptName)); //version44.2 if (t != null) { uiView = uiObject.AddComponent(t) as UIViewBase; break; } } } if (uiView.ID != id) { Debug.LogError(string.Format("<color=cyan>[UIViewBase.ID :{0} != shownWindowId :{1}]</color>", uiView.ID, id)); return(null); } uiView.Controller.Asset = prefab;//version79.4 return(uiView); } return(null); }
public void ReplaceView(string name, Intent intent = null) { if (m_topPage != name && m_UIDataMap.ContainsKey(m_topPage)) { UIData m_UIData = m_UIDataMap[m_topPage]; m_UIData.gameObject.SetActive(false); UIViewBase baseView = m_UIData.gameObject.GetComponent <UIViewBase>(); if (baseView == null) { Debugger.Error(name + " need UIViewBase!"); return; } baseView.OnClose(); foreach (var item in m_UIData.hidenOverView) { ActiveView(item); } OpenView(name, intent); } }
public UIViewBase[] PopupAll() { if (views.Count == 0) { return(null); } UIViewBase current = null; UIViewBase[] allViews = views.ToArray(); for (int i = views.Count - 1; i >= 0; i--) { current = views[i]; views.RemoveAt(i); PopupSingleView(current); } topOrder = 0; return(allViews); }
private void SchemeViewCache(UIViewBase view) { if (view != null) { switch (view.Config.cacheScheme) { case UIViewCacheScheme.Cache: CacheView(view); break; case UIViewCacheScheme.TempCache: TempCacheView(view); break; case UIViewCacheScheme.AutoRemove: ReleaseView(view); break; } } }
private void PopStack(UIViewBase view) { UIContext uiContext; dicContext.TryGetValue(view._showPos, out uiContext); if (uiContext != null) { uiContext.Pop(); if (uiContext._count == 0) { if (uiContext._showPos == UIShowPos.TipTop)//是顶层 下面都继续 { if (dicContext.ContainsKey(UIShowPos.Normal)) { dicContext[UIShowPos.Normal].Resume();//继续 } } } } }
public UIViewBase OpenWindow(string windowID, params object[] args) { if (!m_AllWindows.ContainsKey(windowID)) { return(null); } UIViewBase window = m_AllWindows[windowID]; //m_Sort++; m_PreMinDepths[window.Type] += 2; int m_Sort = m_PreMinDepths[window.Type]; window.Sort = m_Sort; DealWindowStack(window, true); window.Root = CanvasRoot.transform; if (window.MaskType != EWindowMaskType.None) { //EventCenter.Notify(EventID.PlayerEvent_StopJoystick); } if (window.ShowMode == EWindowShowMode.SaveTarget && m_MutexStacks.Count > 0) { UIViewBase w = m_MutexStacks[m_MutexStacks.Count - 1]; window.TargetID = w.ID; } if (m_OpenWindows.Contains(window) == false) { m_OpenWindows.Add(window); } window.SetData(args); window.ShowAsync(); if (window.transform == null) { return(null); } //RefreshDepth(window); RefreshMask(); window.OnLoadSubWindows(); return(window); }
//刷新mask+排序 void ShowMask(UIViewBase needBlackView, UIViewBase needWhiteView) { if (needBlackView != null && needBlackView.transform != null) { MaskBlackTransparent.Sort = needBlackView.Sort - 1; MaskBlackTransparent.gameObject.SetActive(true); MaskBlackTransparent.ClickAction = needBlackView.onMaskClick; } else { MaskBlackTransparent.gameObject.SetActive(false); } if (needWhiteView != null && needWhiteView.transform != null) { MaskWhiteTransparent.Sort = needWhiteView.Sort - 1; MaskWhiteTransparent.gameObject.SetActive(true); MaskWhiteTransparent.ClickAction = needWhiteView.onMaskClick; } else { MaskWhiteTransparent.gameObject.SetActive(false); } m_OpenWindows.Sort((viewBase1, viewBase2) => viewBase1.Sort.CompareTo(viewBase2.Sort));//升序 bool blackFlag = MaskBlackTransparent.gameObject.activeSelf; bool WhiteFlag = MaskWhiteTransparent.gameObject.activeSelf; for (int i = 0; i < m_OpenWindows.Count; i++) { if (blackFlag && MaskBlackTransparent.Sort < m_OpenWindows[i].Sort) { blackFlag = !blackFlag; MaskBlackTransparent.transform.SetAsLastSibling(); } if (WhiteFlag && MaskWhiteTransparent.Sort < m_OpenWindows[i].Sort) { WhiteFlag = !WhiteFlag; MaskWhiteTransparent.transform.SetAsLastSibling(); } m_OpenWindows[i].transform.SetAsLastSibling(); } }
public void CleseView(UIViewId viewId) { if (mOpendViewDic.ContainsKey(viewId)) { UIViewBase viewBase = mOpendViewDic [viewId]; viewBase.Close(); ViewConfigInfo configInfo = mViewConfig [viewId]; GameMain.Instance.ResMgr.UnloadResource(configInfo.prefabName, typeof(GameObject)); } else if (mOpendViewDic.ContainsKey(viewId)) { if (!mWaitCloseingSet.Contains(viewId)) { mWaitCloseingSet.Add(viewId); } } else { Logger.LogWarning("UIManager close not opend or opening view: " + viewId.ToString()); } }
private void ShowFarDropMark() { if (m_dropMarkAdorner == null) { DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); DataGridControl grid = (dataGridContext != null) ? dataGridContext.DataGridControl : null; Pen pen = Xceed.Wpf.DataGrid.Views.UIViewBase.GetDropMarkPen(this); if ((pen == null) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; pen = uiViewBase.DefaultDropMarkPen; } DropMarkOrientation orientation = UIViewBase.GetDropMarkOrientation(this); if ((orientation == DropMarkOrientation.Default) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; orientation = uiViewBase.DefaultDropMarkOrientation; } m_dropMarkAdorner = new DropMarkAdorner(this, pen, orientation); AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { adornerLayer.Add(m_dropMarkAdorner); } } // We Only want the drop mark to be displayed at the end of the HierarchicalGroupByControlNode m_dropMarkAdorner.ForceAlignment(DropMarkAlignment.Far); }
//需要手动注册脚本 private UIViewBase RegisterDlgScripte(string viewName) { UIViewBase view = null; if (!string.IsNullOrEmpty(viewName)) { GameObject uiRoot = CreateRootObj(viewName); switch (viewName) { case UIMovePage.NAME: view = uiRoot.AddComponent <UIMovePage>(); break; case UITimePage.NAME: view = uiRoot.AddComponent <UITimePage>(); break; case UIPromptPage.NAME: view = uiRoot.AddComponent <UIPromptPage>(); break; case UIMovieQRCodePage.NAME: view = uiRoot.AddComponent <UIMovieQRCodePage>(); break; case UIMessagePage.NAME: view = uiRoot.AddComponent <UIMessagePage>(); break; } if (view != null && !dicView.ContainsKey(viewName)) { dicView.Add(viewName, view); } else { GameObject.Destroy(uiRoot); } } return(view); }
internal void ShowDropMark(Point mousePosition) { if (m_dropMarkAdorner == null) { DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); DataGridControl grid = (dataGridContext != null) ? dataGridContext.DataGridControl : null; Pen pen = UIViewBase.GetDropMarkPen(this); if ((pen == null) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; pen = uiViewBase.DefaultDropMarkPen; } DropMarkOrientation orientation = UIViewBase.GetDropMarkOrientation(this); if ((orientation == DropMarkOrientation.Default) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; orientation = uiViewBase.DefaultDropMarkOrientation; } m_dropMarkAdorner = new DropMarkAdorner(this, pen, orientation); AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { adornerLayer.Add(m_dropMarkAdorner); } } m_dropMarkAdorner.UpdateAlignment(mousePosition); }
/// <summary> /// 添加通用的背景UI /// </summary> private void AddColliderBgForWindow(UIViewBase baseWindow) { UIWindowColliderMode colliderMode = baseWindow.windowData.colliderMode; if (colliderMode == UIWindowColliderMode.None) { return; } GameObject bgObj = null; if (colliderMode == UIWindowColliderMode.Normal) { bgObj = GameUIUtility.AddColliderBgToTarget(baseWindow.gameObject, true); } if (colliderMode == UIWindowColliderMode.WithBg) { bgObj = GameUIUtility.AddColliderBgToTarget(baseWindow.gameObject, false, ""); } baseWindow.Controller.OnAddColliderBg(bgObj); }
public virtual void DestroyWindow() { //if (baseView == null) return; //version49 IsActive = false; IsLoading = false; IsExiting = false; BeforeDestroyWindow(); //if (baseView == null) return; //version49 if (baseView != null)//version49 { //销毁 GameObject obj = baseView.gameObject; baseView.Controller = null; baseView = null; GameObject.Destroy(obj); obj = null; } //version79.4 //ResourceComponent.Instance.UnloadAsset(m_UIAsset); }
internal void ShowDropMark(RelativePoint mousePosition) { if (m_dropMarkAdorner == null) { var dataGridContext = DataGridControl.GetDataGridContext(this); var dataGridControl = (dataGridContext != null) ? dataGridContext.DataGridControl : null; var pen = UIViewBase.GetDropMarkPen(this); if ((pen == null) && (dataGridControl != null)) { var uiViewBase = dataGridControl.GetView() as UIViewBase; if (uiViewBase != null) { pen = uiViewBase.DefaultDropMarkPen; } } var orientation = UIViewBase.GetDropMarkOrientation(this); if ((orientation == DropMarkOrientation.Default) && (dataGridControl != null)) { var uiViewBase = dataGridControl.GetView() as UIViewBase; if (uiViewBase != null) { orientation = uiViewBase.DefaultDropMarkOrientation; } } m_dropMarkAdorner = new DropMarkAdorner(this, pen, orientation); var adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { adornerLayer.Add(m_dropMarkAdorner); } } m_dropMarkAdorner.UpdateAlignment(mousePosition); }
public void CloseWindow(string windowID, bool IsPlayAudio = false) { if (IsPlayAudio) { //是否播放关闭音乐 //UIFunc.OnClickBtnNormalClose(); } if (string.IsNullOrEmpty(windowID)) { return; } UIViewBase window = null; if (m_AllWindows.TryGetValue(windowID, out window) == false) { return; } window.HideAsync(); m_OpenWindows.Remove(window); RefreshMask(); DealWindowStack(window, false); }
/// <summary> /// Reacts to the user changing the view type of the grid using radio buttons. /// </summary> private void ViewTypeChanged(object sender, RoutedEventArgs e) { var type = ((RadioButton)sender).Content.ToString(); if (OSLEBotDataGrid == null) { return; //Ignore view switches happening before the view is initialized. } UIViewBase newView = null; switch (type) { case "Cards": newView = TryFindResource("compactCardView") as UIViewBase; break; case "List": newView = TryFindResource("tableView") as UIViewBase; break; case "TableFlow": newView = TryFindResource("tableFlowView") as UIViewBase; break; } if (newView != null) { OSLEBotDataGrid.View = newView; } }
public void OnPointerClick(PointerEventData eventData) { if(m_IsAutoClose) { UIPanelBase panel = this.GetComponentInParent<UIPanelBase>(); if (panel != null) {//如果是panel panel.Close(); } else { UIViewBase view = this.GetComponentInParent<UIViewBase>(); if(view != null) {//如果是view GameObject.Destroy(view.gameObject); } else { GameObject.Destroy(this.gameObject); } } } }
private IEnumerator LoadView(ViewType viewType, object dataObject = null, Action onComplete = null) { _isWaitingForLoading = true; UIViewBase topViewOnStack = GetViewOnTopOfStack(); if (topViewOnStack != null) { topViewOnStack.HideView(); yield return(new WaitUntil(() => topViewOnStack.IsDisabled)); } var viewObject = Instantiate(ViewsObjectsList.First(view => view.Type == viewType).ViewObject); var viewToOpen = viewObject.GetComponent <UIViewBase>(); viewToOpen.SetupView(dataObject); _viewsStack.Add(viewToOpen); yield return(new WaitUntil(() => viewToOpen.IsViewLoaded)); onComplete?.Invoke(); _isWaitingForLoading = false; }