Пример #1
0
    /// <summary>
    /// 根据面板与对象相对路径获取目标对象
    /// </summary>
    /// <param name="panelId">对象依赖面板</param>
    /// <param name="relativePath">相对面板路径</param>
    /// <returns></returns>
    public static GameObject FindGameObjByPanel(PanelID panelId, string relativePath)
    {
        UIPanelBase panelbase = DataManager.Manager <UIPanelManager>().GetPanel(panelId);

        if (null == panelbase)
        {
            if (UIDefine.IsUIDebugLogEnable)
            {
                Engine.Utility.Log.Error("UIManager->FindGameObjByPanel faield,unknow panelId:{0}"
                                         , panelId);
            }
            return(null);
        }

        Transform ts = panelbase.CacheTransform.Find(relativePath);

        if (null == ts)
        {
            if (UIDefine.IsUIDebugLogEnable)
            {
                Engine.Utility.Log.Error("UIManager->FindGameObjByPanel faield,unknow path:{0}\npanelid:{1}"
                                         , relativePath, panelId);
            }
            return(null);
        }
        return(ts.gameObject);
    }
Пример #2
0
    public bool IsOpenUI(out PanelID pid, out int index, out int copyID)
    {
        pid    = PanelID.None;
        index  = 0;
        copyID = 0;
        string strShowUI = "";

        if (!string.IsNullOrEmpty(strShowUI))
        {
            string[] strUI = strShowUI.Split('_');
            if (strUI.Length == 1)
            {
                pid   = (PanelID)System.Enum.Parse(typeof(PanelID), strUI[0]);
                index = 1;
                return(true);
            }
            if (strUI.Length == 2)
            {
                pid   = (PanelID)System.Enum.Parse(typeof(PanelID), strUI[0]);
                index = int.Parse(strUI[1]);
                return(true);
            }
            else if (strUI.Length == 3)
            {
                pid    = (PanelID)System.Enum.Parse(typeof(PanelID), strUI[0]);
                index  = int.Parse(strUI[1]);
                copyID = int.Parse(strUI[2]);
                return(true);
            }
        }
        return(false);
    }
Пример #3
0
    /// <summary>
    /// Method to show a new panel, hiding any panels that are currently active
    /// </summary>
    /// <param name="panel">The panelID of the panel to show</param>
    /// <param name="forceCloseOthers">If we want to force close other panels</param>
    public void ShowPanel(PanelID panel, bool forceCloseOthers = false)
    {
        for (int i = 0; i < panelList.Length; i++)
        {
            // if we found the panel we want to go to
            if (panelList[i].panelID == panel)
            {
                panelList[i].gameObject.SetActive(true);    // enable the object
                panelList[i].isActive = true;               // set the active state
                panelList[i].OnShow();                      // call the panels OnShow method

                currentPanel = panelList[i];                // set a reference to the currentPanel
            }
            else if (panelList[i].isActive || forceCloseOthers)
            {
                panelList[i].gameObject.SetActive(false);   // disable the object

                // the force bool is just to disable panels and not call the OnHide()
                if (panelList[i].isActive)
                {
                    panelList[i].isActive = false;          // set the active state
                    panelList[i].OnHide();                  // call the panels onHide method
                }
            }
        }
    }
Пример #4
0
        /// <summary>
        /// 显示界面的预处理
        /// </summary>
        /// <param name="panelID"></param>
        /// <returns></returns>
        private Panel BeforeShowPanel(PanelID panelID)
        {
            if (IsPanelShown(panelID))
            {
                Log.Warn(String.Format("{0} panel have been shown!", panelID.ToString()));
                return(null);
            }

            Panel basePanel = GetGamePanel(panelID);

            if (basePanel == null)
            {
                Assert.IsTrue(UIConfig.BundleName.ContainsKey(panelID));
                GameObject prefab = ResManager.Instance.Load <GameObject>(
                    UIConfig.BundleName[panelID],
                    panelID.ToString() + UIConfig.Suffix
                    );
                Assert.IsNotNull <GameObject>(prefab);
                GameObject goPanel = GameObject.Instantiate(prefab, normalCanvas);
                goPanel.SetActive(false);
                basePanel = goPanel.GetComponent <Panel>();
                Assert.AreEqual <PanelID>(panelID, basePanel.PanelID);
                RectTransform targetRoot = GetCanvasRoot(basePanel.PanelData.Type);
                goPanel.transform.SetParent(targetRoot);
                goPanel.name       = panelID.ToString();
                allPanels[panelID] = basePanel;
            }
            return(basePanel);
        }
Пример #5
0
 /// <summary>
 /// 添加一个获取了焦点的面板
 /// </summary>
 /// <param name="panelID"></param>
 public void AddFocusPanel(PanelID panelID)
 {
     if (null != m_lst_curFocusPanels && !m_lst_curFocusPanels.Contains(panelID))
     {
         m_lst_curFocusPanels.Add(panelID);
     }
 }
Пример #6
0
    /// <summary>
    /// 刷新新功能UI状态
    /// </summary>
    /// <param name="funcId"></param>
    private void RefreshNewFuncUIStatus(uint funcId)
    {
        GuideDefine.LocalFuncOpenData localData = null;

        if (null != m_dic_funcOpenDatas && m_dic_funcOpenDatas.TryGetValue(funcId, out localData))
        {
            PanelID dependPanelId = localData.FuncCreateObjPathData.DependPanelId;
            if (dependPanelId == PanelID.None || !DataManager.Manager <UIPanelManager>().IsShowPanel(dependPanelId))
            {
                //Engine.Utility.Log.Error("GuideManger->RefreshNewFuncUIStatus faield,relative panel panelId:{0}"
                //    , localData.FuncCreateObjPathData.DependPanelId);
                return;
            }
            GameObject obj = localData.CreateFuncObj;
            if (null != obj)
            {
                bool funcOpen = IsNewFuncOpen(funcId);
                if (funcOpen && localData.NeedSort)
                {
                    obj.transform.localPosition = GetNewFuncObjTargetPos(funcId);
                }
                if (obj.activeSelf != funcOpen)
                {
                    obj.SetActive(funcOpen);
                }
            }
        }
        else
        {
            Engine.Utility.Log.Error("GuideManger->RefreshNewFuncUIStatus faield,can't found funcId:{0}", funcId);
        }
    }
Пример #7
0
 /// <summary>
 ///添加显示面板
 /// </summary>
 /// <param name="panelID"></param>
 private void AddShowPanel(PanelID panelID)
 {
     if (!IsShowPanel(panelID))
     {
         showPanels.Add((uint)panelID);
     }
 }
Пример #8
0
        /// <summary>
        /// 当前面板是否可以缓存pid
        /// </summary>
        /// <param name="pType"></param>
        /// <returns></returns>
        public bool CanCachePanel(PanelID pid)
        {
            PanelCacheLv cacheLv = CacheLv;

            if (cacheLv == PanelCacheLv.None || IsStartPanel)
            {
                return(false);
            }


            bool           canCache = false;
            LocalPanelInfo localP2  = null;

            if (DataManager.Manager <UIPanelManager>().TryGetLocalPanelInfo(pid, out localP2) && !localP2.IgnoreCache)
            {
                if (cacheLv == PanelCacheLv.All)
                {
                    canCache = true;
                }
                else
                {
                    PanelRootType r1 = UIRootHelper.Instance.GetRootTypePanelType(PType);
                    PanelRootType r2 = UIRootHelper.Instance.GetRootTypePanelType(localP2.PType);
                    canCache = (r1 >= r2);
                    if (!canCache && CacheLv == PanelCacheLv.Dialog &&
                        r2 == PanelRootType.PopUp)
                    {
                        canCache = true;
                    }
                }
            }
            return(canCache);
        }
Пример #9
0
    /// <summary>
    ///刷新
    /// </summary>
    /// <param name="pid"></param>
    private void RefreshGuideTargetObj(PanelID pid)
    {
        GuideDefine.LocalGuideGroupData localGroupData = null;
        GuideDefine.LocalGuideData      localGuideData = null;
        if (null != CurDoUnConstraintGuide && CurDoUnConstraintGuide.Count > 0)
        {
            var iemurator = CurDoUnConstraintGuide.GetEnumerator();
            while (iemurator.MoveNext())
            {
                localGroupData = iemurator.Current.Value;
                if (null == localGroupData || !localGroupData.LoopTrigger)
                {
                    continue;
                }
                if (localGroupData.CurStep != 0 &&
                    TryGetGuideLocalData(localGroupData.CurStep, out localGuideData) &&
                    localGuideData.GuideTargetDependPanel == pid)
                {
                    localGuideData.GuideTargetObj = null;
                }
            }
        }

        if (null != CurDoRepeatUnConstraintGuide)
        {
            if (CurDoRepeatUnConstraintGuide.CurStep != 0 &&
                TryGetGuideLocalData(CurDoRepeatUnConstraintGuide.CurStep, out localGuideData) &&
                localGuideData.GuideTargetDependPanel == pid)
            {
                localGuideData.GuideTargetObj = null;
            }
        }
    }
Пример #10
0
 /// <summary>
 /// 添加加载状态
 /// </summary>
 /// <param name="pid"></param>
 private void AddLoadingMask(PanelID pid)
 {
     if (!IsLoadingPanel(pid))
     {
         m_lstLoadingPanel.Add(pid);
     }
 }
Пример #11
0
 /// <summary>
 /// 面板隐藏回掉
 /// </summary>
 /// <param name="pid"></param>
 private void OnPanelHide(PanelID pid)
 {
     //Debug.LogError("-------HidePanel pid=" + pid + ",waitingpanelsize:" + m_lstWaitingShow.Count);
     if (IsShowPanel(pid))
     {
         RemoveHidePanel(pid);
     }
 }
Пример #12
0
 /// <summary>
 /// 从获取焦点的面板列表中移除
 /// </summary>
 /// <param name="panelID"></param>
 /// <returns></returns>
 public bool RemoveFocusPanel(PanelID panelID)
 {
     if (null != m_lst_curFocusPanels)
     {
         return(m_lst_curFocusPanels.Remove(panelID));
     }
     return(false);
 }
Пример #13
0
    /// <summary>
    /// 创建面板
    /// </summary>
    /// <param name="pid">面板ID</param>
    /// <param name="panelTs">依赖的Transform</param>
    /// <returns></returns>
    private UIPanelBase CreatePanel(PanelID pid, Transform panelTs)
    {
        UIPanelBase panelBase = GetPanel(pid);

        if (null == panelTs)
        {
            Engine.Utility.Log.Error("UIPanelManager->CreatePanel failed ,Panel Transform null,PID:{0}", pid);
            return(panelBase);
        }

        LocalPanelInfo localPanelInfo = null;

        if (TryGetLocalPanelInfo(pid, out localPanelInfo))
        {
            if (null == panelBase)
            {
                string     panelPath      = localPanelInfo.PrefabPath;
                string     panelClassName = localPanelInfo.PanelEnumName;
                GameObject go             = panelTs.gameObject;

                if (!string.IsNullOrEmpty(panelClassName))
                {
                    go.name   = panelClassName;
                    panelBase = go.GetComponent <UIPanelBase>();
                    if (null == panelBase)
                    {
                        panelBase = Util.AddComponent(go, panelClassName) as UIPanelBase;
                        if (null != panelBase)
                        {
                            panelBase.PanelInfo = localPanelInfo;
                            if (null != go && !go.activeSelf)
                            {
                                go.SetActive(true);
                            }
                            //初始化
                            panelBase.Init();
                            panelBase.InitPanelDetph();
                            //go.SetActive(false);
                        }
                    }
                    allPanels.Add((uint)pid, panelBase);
                }
            }
            else
            {
                Debug.LogError("DespawnExistpanel:" + pid.ToString());
                if (IsShowPanel(pid))
                {
                    Debug.LogError("DespawnExistSSS##panel:" + pid.ToString());
                }
                UIManager.ReleaseObjs(localPanelInfo.TableData.resID, panelTs);
            }
        }

        return(panelBase);
    }
Пример #14
0
    /// <summary>
    /// 获取panel
    /// </summary>
    /// <param name="panelId"></param>
    /// <returns></returns>
    public UIPanelBase GetPanel(PanelID panelId)
    {
        UIPanelBase pb = null;

        if (allPanels.TryGetValue((uint)panelId, out pb))
        {
            return(pb);
        }
        return(null);
    }
Пример #15
0
    /// <summary>
    /// 获取面板
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="panelId"></param>
    /// <returns></returns>
    public T GetPanel <T>(PanelID panelId) where T : UIPanelBase
    {
        UIPanelBase panel = GetPanel(panelId);

        if (null != panel && panel is T)
        {
            return(panel as T);
        }
        return(null);
    }
Пример #16
0
    /// <summary>
    /// 异步加载面板
    /// </summary>
    /// <param name="pid"></param>
    /// <param name="panelCreateAction"></param>
    private void LoadingPanelAsyn(PanelID pid)
    {
        LocalPanelInfo panelInfo = null;

        if (TryGetLocalPanelInfo(pid, out panelInfo) && !IsPanelReady(pid) && !IsLoadingPanel(pid))
        {
            AddLoadingMask(pid);
            UIManager.GetObjAsyn(panelInfo.TableData.resID, OnPanelTransformAsynLoad, pid);
        }
    }
Пример #17
0
        public static PanelStatusData Create(PanelID panelId, PanelStatus status, GameObject obj = null)
        {
            PanelStatusData statusData = new PanelStatusData()
            {
                ID     = panelId,
                Status = status,
                Obj    = obj,
            };

            return(statusData);
        }
Пример #18
0
 private Panel GetGamePanel(PanelID panelID)
 {
     if (allPanels.ContainsKey(panelID))
     {
         return(allPanels[panelID]);
     }
     else
     {
         return(null);
     }
 }
Пример #19
0
    /// <summary>
    /// 释放面板
    /// </summary>
    /// <param name="panelId"></param>
    /// <param name="dlg"></param>
    /// <returns></returns>
    public void ReleasePanel(PanelID panelId, Action dlg = null)
    {
        UIPanelBase pb = null;

        if (null != allPanels && allPanels.TryGetValue((uint)panelId, out pb))
        {
            if (IsShowPanel(pb.PanelId))
            {
                HidePanel(pb.PanelId, false, dlg);
            }
        }
    }
Пример #20
0
 /// <summary>
 /// 判断指定界面是否正在显示
 /// </summary>
 public bool IsPanelShown(PanelID panelID)
 {
     if (shownPopupPanels.ContainsKey(panelID) || shownFixedPanels.ContainsKey(panelID))
     {
         return(true);
     }
     if (curNormalPanel != null && curNormalPanel.PanelID == panelID)
     {
         return(true);
     }
     return(false);
 }
Пример #21
0
    public void SendMsg(PanelID id, UIMsgID msgid, object param)
    {
        if (!IsShowPanel(id))
        {
            return;
        }
        UIPanelBase panelBase = GetPanel(id);

        if (null != panelBase)
        {
            panelBase.OnMsg(msgid, param);
        }
    }
Пример #22
0
    /// <summary>
    /// 是否游戏对象相对面板可见
    /// </summary>
    /// <param name="dependPanel"></param>
    /// <param name="relativePath"></param>
    /// <returns></returns>
    public static bool IsUIObjVisible(PanelID dependPanel, GameObject obj)
    {
        if (null == obj || !obj.gameObject.activeSelf)
        {
            return(false);
        }

        bool        dependShow = DataManager.Manager <UIPanelManager>().IsShowPanel(dependPanel);
        UIPanelBase panelBase  = DataManager.Manager <UIPanelManager>().GetPanel(dependPanel);

        if (null == panelBase || panelBase.Panel)
        {
            return(false);
        }
        UIPanel   panel             = panelBase.Panel;
        UIWidget  widget            = obj.GetComponent <UIWidget>();
        bool      isVisible         = false;
        Bounds    bounds            = NGUIMath.CalculateRelativeWidgetBounds(obj.transform, obj.transform);
        Matrix4x4 local2WorldMatrix = obj.transform.localToWorldMatrix;

        Vector3[] boundsVector = new Vector3[4];
        boundsVector[0] = new Vector3(bounds.min.x, bounds.min.y, 1);
        boundsVector[1] = new Vector3(bounds.min.x, bounds.max.y, 1);
        boundsVector[2] = new Vector3(bounds.max.x, bounds.max.y, 1);
        boundsVector[3] = new Vector3(bounds.max.x, bounds.min.y, 1);
        for (int i = 0; i < 4; i++)
        {
            boundsVector[i] = local2WorldMatrix.MultiplyPoint3x4(boundsVector[i]);
        }
        isVisible = dependShow && panel.IsVisible(boundsVector[0], boundsVector[1], boundsVector[2], boundsVector[3]);
        //if (null == widget)
        //{
        //    Bounds bounds = NGUIMath.CalculateRelativeWidgetBounds(obj.transform, obj.transform);
        //    Matrix4x4 local2WorldMatrix = obj.transform.localToWorldMatrix;
        //    Vector3[] boundsVector = new Vector3[4];
        //    boundsVector[0] = new Vector3(bounds.min.x, bounds.min.y, 1);
        //    boundsVector[1] = new Vector3(bounds.min.x, bounds.max.y, 1);
        //    boundsVector[2] = new Vector3(bounds.max.x, bounds.max.y, 1);
        //    boundsVector[3] = new Vector3(bounds.max.x, bounds.min.y, 1);
        //    for (int i = 0; i < 4; i++)
        //    {
        //        boundsVector[i] = local2WorldMatrix.MultiplyPoint3x4(boundsVector[i]);
        //    }
        //    isVisible = dependShow && panel.IsVisible(boundsVector[0], boundsVector[1], boundsVector[2], boundsVector[3]);
        //}
        //else
        //{
        //    isVisible = dependShow && panel.IsVisible(widget);
        //}
        return(isVisible);
    }
Пример #23
0
    /// <summary>
    /// 移除隐藏面板
    /// </summary>
    /// <param name="panelID"></param>
    private void RemoveHidePanel(PanelID panelID)
    {
        UIPanelBase panel = null;
        uint        pid   = (uint)panelID;

        if (IsShowPanel(panelID))
        {
            showPanels.Remove(pid);
        }
        if (allPanels.TryGetValue(pid, out panel))
        {
            allPanels.Remove(pid);
            //Debug.LogError("p2:" + panel.CacheTransform.GetInstanceID());
            UIManager.OnObjsRelease(panel.CacheTransform, panel.PanelInfo.TableData.resID);
        }
    }
Пример #24
0
 /// <summary>
 /// 处理面板显示互斥
 /// </summary>
 /// <param name="pid"></param>
 private void DealShowPanelMutex(PanelID pid)
 {
     if (pid == PanelID.CommonBgPanel || pid == PanelID.TopBarPanel)
     {
         return;
     }
     if (null != m_lstWaitingShow && m_lstWaitingShow.Count > 0)
     {
         PanelShowData pSD = m_lstWaitingShow[0];
         if (pSD.PID == pid)
         {
             m_lstWaitingShow.RemoveAt(0);
         }
         ProccessPanelShowing();
     }
 }
Пример #25
0
    /// <summary>
    /// 面板Transform加载完成回调
    /// </summary>
    /// <param name="panelTs"></param>
    /// <param name="param1"></param>
    /// <param name="param2"></param>
    /// <param name="param3"></param>
    private void OnPanelTransformAsynLoad(Transform panelTs, object param1, object param2, object param3)
    {
        if (null == panelTs)
        {
            Engine.Utility.Log.Error("UIPanelManager->OnPanelTransformAsynLoad null pid ={0}", param1.ToString());
            return;
        }

        PanelID pid = (PanelID)param1;

        //移除加载状态
        RemoveLoadingMask(pid);
        UIPanelBase createPanelBase = CreatePanel(pid, panelTs);

        ProccessPanelShowing();
    }
Пример #26
0
    /// <summary>
    /// 刷新新功能状态
    /// </summary>
    /// <param name="panelId">是否显示刷新单个panel</param>
    private void DoRefreshNewFuncOpenStaus(PanelID panelId = PanelID.None)
    {
        bool matchPanel = (panelId != PanelID.None);

        if (null != m_dic_funcOpenDatas)
        {
            var enumerator = m_dic_funcOpenDatas.GetEnumerator();
            while (enumerator.MoveNext())
            {
                if (matchPanel && enumerator.Current.Value.FuncCreateObjPathData.DependPanelId != panelId)
                {
                    continue;
                }
                RefreshNewFuncUIStatus(enumerator.Current.Key);
            }
        }
    }
Пример #27
0
 /// <summary>
 /// 刷新当前焦点数据
 /// </summary>
 /// <param name="status"></param>
 private void RefreshFocusDatas(PanelID panelID, bool cansee)
 {
     if (!cansee)
     {
         if (RemoveFocusPanel(panelID))
         {
             Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.UIEVENT_PANELFOCUSSTATUSCHANGED, new PanelFocusData()
             {
                 ID       = panelID,
                 GetFocus = false,
             });
         }
     }
     else
     {
         CheckFocusDatas(panelID);
     }
 }
Пример #28
0
    /// <summary>
    /// 是否下一个将要显示的面板ready
    /// </summary>
    /// <param name="pid"></param>
    /// <returns></returns>
    private bool IsNextShowPanelReady(ref PanelID pid)
    {
        nextShowPanelID = PanelID.None;
        bool ready = false;

        if (m_lstWaitingShow.Count > 0)
        {
            PanelShowData nextShowData = m_lstWaitingShow[0];
            nextShowPanelID = nextShowData.PID;
            LocalPanelInfo localInfo = null;
            if (TryGetLocalPanelInfo(pid, out localInfo))
            {
                ready = IsPanelAssetReady(localInfo);
            }
        }

        return(ready);
    }
Пример #29
0
    /// <summary>
    /// 隐藏面板
    /// </summary>
    /// <param name="id">面板id</param>
    /// <param name="ignoreCacheBack">是否忽略cacheBack</param>
    /// <param name="action"></param>
    /// <param name="needDestroy"></param>
    /// <param name="?"></param>
    public void HidePanel(PanelID id, bool needReturnBack, Action action = null)
    {
        if (!IsShowPanel(id))
        {
            return;
        }

        UIPanelBase panel        = GetPanel(id);
        int         pid          = (int)id;
        Action      hideCallback = () =>
        {
            LocalPanelInfo lp = null;
            if (TryGetLocalPanelInfo(id, out lp) && lp.PanelTaData.Enable)
            {
                UIFrameManager.Instance.ResetTabs();
            }
            if (needReturnBack)
            {
                if (panel.PanelInfo.CacheLv != PanelCacheLv.None)
                {
                    OnPanelCacheBack(id);
                }
                //如果有前置面板,显示前置面板
                if (null != panel.PrePanelData && panel.PrePanelData.PID != PanelID.None)
                {
                    ShowPanel(panel.PrePanelData.PID
                              , prePanelData: panel.PrePanelData.PrePanelData
                              , data: panel.PrePanelData.Data, jumpData: panel.PrePanelData.JumpData);
                }
            }
            //主界面影藏,根节点也隐藏
            //if (id == PanelID.MainPanel)
            //{
            //    UIRootHelper.Instance.SetPanelRootStatusByType(PanelRootType.Main,false);
            //}
        };

        if (null != action)
        {
            hideCallback += action;
        }

        panel.HidePanel(hideCallback);
    }
Пример #30
0
 public T Get <T>(PanelID id) where T : UIPanel
 {
     if (_registeredPanels.ContainsKey(id))
     {
         if (_registeredPanels[id] is T)
         {
             return(_registeredPanels[id] as T);
         }
         else
         {
             Debug.LogError("UIPanel mathcing ID '" + id.ToString() + "' is not of type '" + typeof(T).ToString() + "'.");
         }
     }
     else
     {
         Debug.LogError("No UIPanel with id '" + id.ToString() + "' registered with UIManager.");
     }
     return(null);
 }