/// <summary> /// 根据面板类型 得到实例化的面板 /// </summary> /// <returns></returns> private BasePanel GetPanel(UIPanelType panelType) { if (panelDict == null) { panelDict = new Dictionary <UIPanelType, BasePanel>(); } //BasePanel panel; //panelDict.TryGetValue(panelType, out panel);//TODO BasePanel panel = panelDict.TryGet(panelType); if (panel == null) { //如果找不到,那么就找这个面板的prefab的路径,然后去根据prefab去实例化面板 //string path; //panelPathDict.TryGetValue(panelType, out path); string path = panelPathDict.TryGet(panelType); GameObject instPanel = GameObject.Instantiate(Resources.Load(path)) as GameObject; instPanel.transform.SetParent(CanvasTransform, false); instPanel.GetComponent <BasePanel>().UIMng = this; instPanel.GetComponent <BasePanel>().Facade = facade; panelDict.Add(panelType, instPanel.GetComponent <BasePanel>()); return(instPanel.GetComponent <BasePanel>()); } else { return(panel); } }
private IEnumerator UpdatePanelOperation(UIPanelType type, DataProvider data = null) { var panel = m_panels[type]; panel.UpdateData(data); yield return(null); }
private void HidePanelData(UIPanelType type) { var panel = m_panels[type]; OnPanelHide?.Invoke(panel); panel.Hide(); if (m_deactivatedPanels.Contains(type)) { m_deactivatedPanels.Remove(type); } if (m_subpanels.ContainsKey(type)) { var subpanel = m_subpanels[type]; m_subpanels.Remove(type); if (m_panels.ContainsKey(subpanel)) { HidePanelData(subpanel); } } if (panel.PanelSettings.MUnLoadMode == UIPanelUnLoadMode.Destroy) { UnloadPanel(type); } else { panel.gameObject.SetActive(false); } }
private IEnumerator ShowSubpanelOperation(UIPanelType ownerType, UIPanelType type, DataProvider data = null) { if (m_operationCoroutine != null) { StopCoroutine(m_operationCoroutine); } if (m_panels.ContainsKey(type)) { ShowPanelData(type, data); var panel = m_panels[type]; if (m_panels[ownerType].SubpanelHolder != null) { SetSubPanel(m_panels[ownerType], panel); } OnPanelShowed?.Invoke(panel); Log("OnPanelShowed " + panel.PanelType); } else { yield return(StartCoroutine(ShowPanelAsync(ownerType, type, data))); } m_operationCoroutine = null; }
private void ShowPanelData(UIPanelType type, DataProvider data = null) { var panel = m_panels[type]; panel.gameObject.SetActive(true); if (m_deactivatedPanels.Contains(type)) { m_deactivatedPanels.Remove(type); } if (panel.PanelState == UIPanelState.Deactivate || panel.PanelState == UIPanelState.Show) { if (panel.PanelState == UIPanelState.Deactivate) { panel.PanelState = UIPanelState.Show; } panel.UpdateData(data); Log("Just UpdateData " + panel.PanelType); } else { panel.ShowData(data); panel.UpdateData(data); } panel.ShowInMaxLayer(); //UiDataProvider.SoundService.PlayBgm("ShowPanel"); }
public void CloseWindowUI(UIPanelType windowType, bool isOpenWindow = false) { if (mWindowDic.ContainsKey(windowType)) { ShowWindow(mWindowDic[windowType], false); } }
public UIPanelOperationWithOwner(OperationType type, UIPanelType owner, UIPanelType panel, DataProvider data = null) : base(type, panel, data) { Type = type; OwnerPanelType = owner; PanelType = panel; Data = data; }
private BasePanel GetPanel(UIPanelType panelType) { if (panelDist == null) { panelDist = new Dictionary <UIPanelType, BasePanel>(); } BasePanel panel; //panelDist.TryGetValue(panelType,out panel); panel = panelDist.TryGet(panelType); if (panel == null) { string path = panelPathDist.TryGet(panelType); GameObject instPanel = GameObject.Instantiate(Resources.Load(path)) as GameObject; instPanel.transform.SetParent(CanvasTransform, false); panelDist.Add(panelType, instPanel.GetComponent <BasePanel>()); return(instPanel.GetComponent <BasePanel>()); } else { return(panel); } }
//通过界面类型获取UI界面 private BasePanle GetPanel(UIPanelType panelType) { if (panelDict == null)//界面字典判空,如果为空则实例化对象 { panelDict = new Dictionary <UIPanelType, BasePanle>(); } BasePanle panel = panelDict.TryGet(panelType);//获取panelType存放的键值相关联的对象 //Debug.Log(panel); if (panel == null) //将使用过的UI界面对象转存到Dictionary<UIPanelType, BasePanle>字典中,省去每次加载界面都通过path路径从UIPanelType.json里面读取 { string path = panelPathDict.TryGet(panelType); //从Dictionary<UIPanelType, string>字典中加载panelType保存的键值相关联的路径 GameObject instPanel = GameObject.Instantiate(Resources.Load(path)) as GameObject; //通过路径寻找到游戏物体 instPanel.transform.SetParent(CanvasTransform, false); //将CanvasTransform游戏物体设置成instPanel所代表的游戏物体的父节点 instPanel.GetComponent <BasePanle>().UIMng = this; //使BasePanel持有本对象--UIManager对象的引用 instPanel.GetComponent <BasePanle>().Focade = facade; panelDict.Add(panelType, instPanel.GetComponent <BasePanle>()); //向Dictionary<UIPanelType, BasePanle>字典加入数据 return(instPanel.GetComponent <BasePanle>()); } else { return(panel); } }
//根据面板类型UIPanelType得到实例化的面板 private BasePanel GetPanel(UIPanelType panelType) { if (panelDict == null)//如果panelDict字典为空,就实例化一个空字典 { panelDict = new Dictionary <UIPanelType, BasePanel>(); } //BasePanel panel; //panelDict.TryGetValue(panelType, out panel);//不为空就根据类型得到Basepanel BasePanel panel = panelDict.TayGet(panelType); //我们扩展的Dictionary的方法,代码作用同上两行 if (panel == null) //如果得到的panel为空,那就去panelPathDict字典里面根据路径path找到,然后加载,接着实例化 { string path = panelPathDict.TayGet(panelType); //我们扩展的Dictionary的方法 //panelPathDict.TryGetValue(panelType, out path); GameObject instPanel = GameObject.Instantiate(Resources.Load(path)) as GameObject; //根据路径加载并实例化面板 instPanel.transform.SetParent(this.CanvasTransform, false); //设置为Canvas的子物体,false表示实例化的子物体坐标以Canvas为准 instPanel.transform.name = panelType.ToString() + "Panel"; panelDict.Add(panelType, instPanel.GetComponent <BasePanel>()); return(instPanel.GetComponent <BasePanel>()); } else { return(panel); } }
public void RemovePanelList(UIPanelType uIPanelType) //页面出队 { if (panelList == null) { panelList = new List <BasePanel>(); } if (panelList.Count <= 0) { return; } if (panelList.IndexOf(GetPanel(uIPanelType)) < 0) { return; } BasePanel removePanel = GetPanel(uIPanelType); //Debug.Log(removePanel.name + "出队"); panelList.Remove(removePanel); //页面销毁后清除字典中的垃圾数据 panelDict.Remove(removePanel.GetUIPanelType()); removePanel.OnExit(); //调用栈顶页面退出事件 if (panelStack != null) //对栈内面板响应对应的时间系统 { panelStack.Peek().ListPanelRemoveEvent(uIPanelType); } }
public void OpenWin(UIPanelType type, Vector3 pos, bool closeOther = false) { BasePanel panel = UIPanelRegister.GetPanel(type); if (panelStack.Count != 0) { BasePanel top = null; if (closeOther) { top = panelStack.Pop(); } else { top = panelStack.Peek(); } if (null != top) { top.OnExit(); } } panel.transform.localPosition = pos; panel.OnEnter(); panelStack.Push(panel); }
private BasePanel GetPanel(UIPanelType panelType) { if (panelDict == null) { panelDict = new Dictionary <UIPanelType, BasePanel>(); } //BasePanel panel; //panelDict.TryGetValue(panelType, out panel); BasePanel panel = panelDict.TryGet(panelType); if (panel == null) { //如果找不到,那么就找这个面板的Prefab路径 //string path; //panelPathDict.TryGetValue(panelType, out path); string path = panelPathDict.TryGet(panelType); GameObject _instancePanel = GameObject.Instantiate(Resources.Load(path)) as GameObject; _instancePanel.transform.SetParent(CanvasTransform, false); panelDict.Add(panelType, _instancePanel.GetComponent <BasePanel>()); panel = _instancePanel.GetComponent <BasePanel>(); } return(panel); }
public void ClosePanel(UIPanelType type) { if (_panelDic.ContainsKey(type)) { ClosePanel(_panelDic[type]); } }
//点击功能模块按钮加载面板,并将其入栈 public void OnPushPanel(string panelTypeString) { //把一个字符串转化为对应的枚举类型 UIPanelType panelType = (UIPanelType)System.Enum.Parse(typeof(UIPanelType), panelTypeString); UIManager.Instance.PushPanel(panelType); }
protected virtual void InstantShowPanel(UIPanelType type, DataProvider data = null) { Log("InstantShowPanel " + type); if (m_panels.ContainsKey(type)) { var panel = m_panels[type]; panel.gameObject.SetActive(true); if (m_deactivatedPanels.Contains(type)) { m_deactivatedPanels.Remove(type); } if (panel.PanelState == UIPanelState.Deactivate || panel.PanelState == UIPanelState.Show) { if (panel.PanelState == UIPanelState.Deactivate) { panel.PanelState = UIPanelState.Show; } panel.UpdateData(data); Log("Just UpdateData " + panel.PanelType); } else { panel.ShowData(data); panel.UpdateData(data); } OnPanelShowed?.Invoke(panel); Log("OnPanelShowed " + panel.PanelType); } else { StartCoroutine(InstantShowPanelAsync(type, data)); } }
/// <summary> /// 根据面板类型得到实例化的面板 /// </summary> /// <returns></returns> BasePanel GetPanel(UIPanelType panelType) { if (panelDict == null) { panelDict = new Dictionary <UIPanelType, BasePanel>(); } //BasePanel panel; //panelDict.TryGetValue(panelType, out panel);//TODO BasePanel panel = panelDict.TryGet(panelType); if (panel == null) { //string path; //panelPathDict.TryGetValue(panelType, out path); string path = panelPathDict.TryGet(panelType); GameObject instPanel = GameObject.Instantiate(Resources.Load(path)) as GameObject; instPanel.transform.SetParent(canvasTransform, false); if (!panelDict.ContainsKey(panelType)) { panelDict.Add(panelType, instPanel.GetComponent <BasePanel>()); } else { panelDict[panelType] = instPanel.GetComponent <BasePanel>(); } return(instPanel.GetComponent <BasePanel>()); } else { return(panel); } }
public UIPanelHideOperation(OperationType type, bool forceDeactivate, UIPanelType panel, DataProvider data = null) : base(type, panel, data) { Type = type; ForceDeactivate = forceDeactivate; PanelType = panel; Data = data; }
/// <summary> /// 创建一个面板并且显示 /// </summary> /// <param name="panelType"></param> /// <returns></returns> private BasePanel GetPanel(UIPanelType panelType) { //写字典缓存,类似于对象池 GameObject instPanel = panelCache.TryGetValueByNN(panelType); //判断缓存里面有没有,如果没有,创建新的,如果有拿缓存里的 if (instPanel == null) { //通过名字找路径 string path = ""; foreach (var item in json.PanelList) { Debug.Log("开始查找" + item.PanelName + ":" + item.PanelPath); if (item.PanelName == panelType.ToString()) { path = item.PanelPath; Debug.Log("找到啦" + item.PanelName); } } Debug.Log("新创建创建啦:" + path); instPanel = GameObject.Instantiate(Resources.Load(path)) as GameObject; instPanel.transform.SetParent(CanvasTransform, false); panelCache.Add(panelType, instPanel); } else { Debug.Log("用的缓存"); } return(instPanel.GetComponent <BasePanel>()); }
//反序列化,从文本信息到对象的过程 public void OnBeforeSerialize() { UIPanelType type = (UIPanelType)System.Enum.Parse(typeof(UIPanelType), panelTypeStr); panelType = type; //Debug.Log(panelType); }
public void ShowUIPanelGeneric(UIPanelType type) { GameObject temp = null; switch (type) { case UIPanelType.Debug: break; case UIPanelType.Dialogue: temp = Instantiate(_dialoguePanel); temp.transform.SetParent(_canvas.transform, false); break; case UIPanelType.Menu: break; case UIPanelType.PlayerMenu: break; case UIPanelType.PlayerInteract: temp = Instantiate(_interactPanel); temp.transform.SetParent(_canvas.transform, false); break; } _currentActivePanel = temp; CurrentActivePanel.SetActive(true); }
public BaseUI GetPanel(UIPanelType panelType) { BaseUI panel = null; if (!panelDict.ContainsKey(panelType)) { string name = Enum.GetName(typeof(UIPanelType), panelType); GameObject instPanel = GameObject.Instantiate(Resources.Load("Panel/" + name)) as GameObject; string str = name.Split('_')[2]; if (str == "Normal") { instPanel.transform.SetParent(uiNormal); } else if (str == "3D") { instPanel.transform.SetParent(ui3D); } instPanel.transform.localEulerAngles = Vector3.zero; instPanel.transform.localScale = Vector3.one; RectTransform recTF = (instPanel.transform as RectTransform); recTF.anchoredPosition3D = Vector3.zero; recTF.offsetMax = Vector2.zero; recTF.offsetMin = Vector2.zero; panel = instPanel.GetComponent <BaseUI>(); panelDict.Add(panelType, panel); } else { panel = panelDict[panelType]; } return(panel); }
/// <summary> /// 通过 UIPanelType 获取对应的实体上的 BaseUIPanel 组件 /// </summary> /// <param name="panelType">UIPanel 的枚举类型,代表哪个UIPanel</param> /// <returns>BaseUIPanel 组件</returns> private BaseUIPanel GetUIPanelByPanelType(UIPanelType panelType) { // 安全校验,如果 panelDic 字典为空,则 new 一个 if (panelDic == null) { panelDic = new Dictionary <UIPanelType, BaseUIPanel>(); } // 尝试获取对应 UIPanelType 对象 (这里可以使用扩展方法,一步操作) BaseUIPanel panel; panelDic.TryGetValue(panelType, out panel); //如果未得到对应的 UIPanelType 对象,则 if (panel == null) { // 尝试获取对应 UIPanelType 对象路径 (这里可以使用扩展方法,一步操作) string path; panelPathDic.TryGetValue(panelType, out path); //加载生成对应 UIPanel 实体 //设置 UIPanel 实体父对象 //获取 UIPanel 上的 BaseUIPanel 组件,并添加到字典中 GameObject panelGo = GameObject.Instantiate(Resources.Load(path)) as GameObject; panelGo.transform.SetParent(CanvasTransform, false); panel = panelGo.GetComponent <BaseUIPanel>(); panelDic.Add(panelType, panel); } // 返回获得的 baseUIPanel return(panel); }
public GameObject GetRoot(UIPanelType type) { GameObject go = null; _roots.TryGetValue(type, out go); return(go); }
public void HidePanel(UIPanelType type) { if (m_activeModule.IsPanelShow(type)) { m_activeModule.HidePanel(type); } }
public void Init() { //Init Attributes if (uiPathDict == null) { uiPathDict = new Dictionary <UIPanelType, string>(); } if (PanelDict == null) { PanelDict = new Dictionary <UIPanelType, BasePanel>(); } if (panelstack == null) { panelstack = new Stack <BasePanel>(); } canvas = GameObject.FindObjectOfType <Canvas>().transform; maskPrefab = Resources.Load <GameObject>("Prefabs/UI/Img_Mask"); InitMask(); //Load Json File using LitJson UIPanelPathList pathsList = LoadFromJson(); //Save Json Loaded text to Dictionary foreach (var t in pathsList.panelPathList) { UIPanelType type = (UIPanelType)System.Enum.Parse(typeof(UIPanelType), t.name); uiPathDict.Add(type, t.path); } //uiPathDict.Add(UIPanelType.StartLoadPanel, "Prefabs/UIPanel/StartLoadPanel"); }
/// 根据面板类型 得到实例化的面板 /// 如果panelDict字典内有就返回,如果没就创建,加入字典 private BasePanel GetPanel(UIPanelType panelType) { if (panelDict == null) //如果panelDict字典为空,还没被创建 { panelDict = new Dictionary <UIPanelType, BasePanel>(); //就新建一个新的字典 } //BasePanel panel; //panelDict.TryGetValue(panelType, out panel);//TODO BasePanel panel = panelDict.TryGet(panelType); if (panel == null) //如果没找到,就取得路径实例化他 //string path; //panelPathDict.TryGetValue(panelType, out path); { string path = panelPathDict.TryGet(panelType); GameObject instPanel = GameObject.Instantiate(Resources.Load(path)) as GameObject; instPanel.transform.SetParent(CanvasTransform, false);//这里要加上false,才会在Canvas正常位置显示 panelDict.Add(panelType, instPanel.GetComponent <BasePanel>()); return(instPanel.GetComponent <BasePanel>()); } else { return(panel); } }
public BasePanel GetPanel(UIPanelType panelType) { if (panelDict == null) { panelDict = new Dictionary <UIPanelType, BasePanel>(); } BasePanel panel; panelDict.TryGetValue(panelType, out panel);//TODO if (panel == null) { string path; panelPathDict.TryGetValue(panelType, out path); //实例化 GameObject instPanel = GameObject.Instantiate(Resources.Load(path)) as GameObject; instPanel.transform.SetParent(CanvasTransform);//TODO panelDict.Add(panelType, instPanel.GetComponent <BasePanel>()); return(instPanel.GetComponent <BasePanel>()); } else { return(panel); } }
//获取面板 private BasePanel GetBasePanel(UIPanelType ePanelType) { BasePanel value; _UIPanelObjects.TryGetValue(ePanelType, out value); return(value); }
public UIPanelOperation(OperationType type, UIPanelType panel, DataProvider data = null) { m_id = s_id++; Type = type; PanelType = panel; Data = data; }
public void NotifyPanel(UIPanelType type, string methodName, object param = null) { PanelBase panel = this.GetOpenedPanelByType(type); if (panel != null) { panel.SendMessage(methodName, param,SendMessageOptions.DontRequireReceiver); } }
public void Open(int depth, PanelParam panelParam, UIPanelType backPanel) { UIController.Instance.DisableUICamera(); //Debug.Log("PanelBase Open"); this.SetPanelDepth(depth); this.SetBackPanel(backPanel); this.InitPanel(); this.Open(panelParam); StartCoroutine(this.PlayEffect(true)); this.panelParam = panelParam; }
public void OpenPanel(UIPanelType type, UIPanelType backPanel) { this.OpenPanel(type, null, backPanel); }
public void OpenPanel(UIPanelType type) { this.OpenPanel(type, null, UIPanelType.None); }
public void OpenPanel(UIPanelType type, PanelParam panelParam) { this.OpenPanel(type, panelParam, UIPanelType.None); }
public PanelBase GetOpenedPanelByType(UIPanelType type) { return (this.m_OpenedPanelDic.ContainsKey(type))? this.m_OpenedPanelDic[type] : null; }
protected void SetBackPanel(UIPanelType type) { this.backPanel = type; }
public void ClosePanel(UIPanelType type) { this.m_OpenedPanelDic[type].Close(); this.m_OpenedPanelDic.Remove(type); }
public void TryClosePanel(UIPanelType type) { if (this.m_OpenedPanelDic.ContainsKey(type)) { this.ClosePanel(type); } else { Debug.Log("这个提示可以不用管 Close panel failed " + type + " is not exist"); } }
public void ShowIngotInsufficientAlert(UIPanelType backPanel) { this.RemoveAllTip(); this.HideLoading(); AlertParam alertParam = new AlertParam() { Alert = LocalizationUtils.GetText("Alert.Label.IngotInsufficient"), Option = AlertOptionType.Sure_Cancel }; alertParam.ResultEvent += (result)=> { if (result) { this.TryClosePanel(backPanel); this.OpenPanel(UIPanelType.MallPanel); } }; this.OpenPanel(UIPanelType.AlertPopupPanel, new PanelParam() { Alert = alertParam }); }
public void OpenPanel(UIPanelType type, PanelParam panelParam, UIPanelType backPanel) { PanelBase panel = null; int newDepth = 0; if (this.m_OpenedPanelDic.ContainsKey(type)) { panel = this.m_OpenedPanelDic[type]; newDepth = panel.GetDepth(); } else { panel= PoolMgr.Instance.GetPanel(type); if (panel == null) { Debug.Log("Panel is null " + type); return; } this.m_OpenedPanelDic.Add(type, panel); newDepth = this.GetTopDepth() + 2;//加2的原因是为了保险起见,因为有的时候只加1可能会出现面板重叠 } panel.Open(newDepth, panelParam, backPanel); }
/// <summary> /// 设置当前面板 /// </summary> /// <param name="type"></param> protected void SetThisPanel(UIPanelType type) { this.ThisPanel = type; }