예제 #1
0
파일: UIMgr.cs 프로젝트: happylays/tbb2
    IEnumerator SwitchWndAsync(UIFlag targetID, UIFlag preID, object exData)
    {
        if (targetID != UIFlag.none)
        {
            if (!IsUIShowing(targetID))
            {
                UIWnd targetWnd = GetUIWnd(targetID);
                if (targetWnd != null)
                {
                    targetWnd.gameObject.SetActive(true);
                    m_lstShowUIID.Add(targetID);


                    targetWnd.ReadyShow = false;

                    WndData targetData = new WndData(exData);
                    targetWnd.PreWndID = preID;
                    targetWnd.OnShowWnd(targetData);

                    while (!targetWnd.ReadyShow)
                    {
                        yield return(null);
                    }
                }
                else
                {
                    Debug.LogError("ui should be prepared before switched: " + targetID.ToString());
                }
            }
        }
    }
예제 #2
0
파일: UIMgr.cs 프로젝트: happylays/tbb2
    IEnumerator PrepareWndAsync(UIFlag uiID)
    {
        if (uiID != UIFlag.none)
        {
            UIWnd uiWnd = GetUIWnd(uiID);
            if (uiWnd == null)
            {
                if (!IsUICaching(uiID))
                {
                    m_lstCacheUIID.Add(uiID);

                    IEnumerator itor = UIWndLoader.LoadUIWndAsync(uiID.ToString(), false);
                    while (itor.MoveNext())
                    {
                        yield return(null);
                    }

                    uiWnd = GetUIWnd(uiID);
                    if (uiWnd != null)
                    {
                        uiWnd.gameObject.SetActive(false);
                    }
                    else
                    {
                        Debug.LogError("prepare ui failed: " + uiID.ToString());
                    }
                }
            }
        }
    }
예제 #3
0
파일: UIMgr.cs 프로젝트: happylays/tbb2
    public static IEnumerator CloseUIAsync(UIWnd uiWnd)
    {
        IEnumerator itor = uimgr.CloseWnd(uiWnd);

        while (itor.MoveNext())
        {
            yield return(null);
        }
    }
예제 #4
0
파일: UIMgr.cs 프로젝트: happylays/tbb2
    void RegisterWnd(UIWnd uiWnd)
    {
        if (uiWnd != null && uiWnd.UIID != UIFlag.none)
        {
            AudioListener[] arListener     = uiWnd.GetComponentsInChildren <AudioListener>();
            int             listenerLength = arListener.Length;
            for (int i = 0; i < listenerLength; ++i)
            {
                if (arListener[i] != null)
                {
                    GameObject.Destroy(arListener[i]);
                }
            }

            ///set ui layer
            CommonFunc.SetLayer(uiWnd.gameObject, GameLayer.UI, true, GameLayer.NONE);

            ///set camera mask
            Camera ca = uiWnd.camera;
            if (ca != null)
            {
                int uiMask = (1 << (int)GameLayer.UI);
                ca.cullingMask |= uiMask;

                UICamera uiCa = uiWnd.GetComponent <UICamera>();
                if (uiCa != null)
                {
                    uiCa.eventReceiverMask |= uiMask;
                }
            }

            ///set label font
            GlobalFunc.SetFont(uiWnd.gameObject);

            ///Set camera clearFlag
            GlobalFunc.SetCameraClearFlags(uiWnd.gameObject, CameraClearFlags.Depth, CameraClearFlags.Nothing);

            if (m_mapAllUIWnd.ContainsKey(uiWnd.UIID))
            {
                Debug.LogError("ui already register, please check : " + uiWnd.UIID.ToString());
            }
            else
            {
                m_mapAllUIWnd.Add(uiWnd.UIID, uiWnd);
                m_lstCacheUIID.Remove(uiWnd.UIID);
            }
        }
    }
예제 #5
0
파일: UIMgr.cs 프로젝트: happylays/tbb2
    void HideWndSync(UIFlag hideID)
    {
        if (hideID != UIFlag.none)
        {
            if (IsUIShowing(hideID))
            {
                m_lstShowUIID.Remove(hideID);

                UIWnd hideWnd = GetUIWnd(hideID);
                if (hideWnd != null)
                {
                    hideWnd.OnHideWnd();
                    hideWnd.gameObject.SetActive(false);
                }
            }
        }
    }
예제 #6
0
파일: UIMgr.cs 프로젝트: happylays/tbb2
    IEnumerator DestoryAllWndAsync()
    {
        UICoroutine.uiCoroutine.gameObject.SetActive(false);            //停止所有UICoroutine
        UICoroutine.uiCoroutine.gameObject.SetActive(true);

        int showIDCount = m_lstShowUIID.Count;

        for (int i = 0; i < showIDCount; ++i)
        {
            UIFlag hideID  = m_lstShowUIID[i];
            UIWnd  hideWnd = GetUIWnd(hideID);
            if (hideWnd != null)
            {
                hideWnd.OnHideWnd();
                hideWnd.gameObject.SetActive(false);
            }
        }

        m_lstShowUIID.Clear();

        Dictionary <UIFlag, UIWnd> mapAllMap = new Dictionary <UIFlag, UIWnd>(m_mapAllUIWnd);

        m_mapAllUIWnd.Clear();
        m_lstCacheUIID.Clear();

        foreach (KeyValuePair <UIFlag, UIWnd> kvp in mapAllMap)
        {
            if (kvp.Value != null && kvp.Value.gameObject)
            {
                GameObject.Destroy(kvp.Value.gameObject);

                yield return(null); //wait for a frame
            }
            UIWndLoader.ReleaseUIWnd(kvp.Key.ToString());
        }
        mapAllMap.Clear();

        ////DynamicPrefabMgr.Instance.OnDestroyUI();
        UIWndLoader.ReleaseAllUIWnd();                  //check again
        UIAtlasLoader.ReleaseAllAtlas();
        //TipsBoxMgr.HideAllTipsBox();
        //MsgWaitMgr.StopWaiting();

        //LoadingMgr.HideViolently();
    }
예제 #7
0
파일: UIMgr.cs 프로젝트: happylays/tbb2
    IEnumerator CloseWnd(UIWnd uiWnd)
    {
        if (uiWnd != null)
        {
            IEnumerator itor = null;
            HideWndSync(uiWnd.UIID);

            ///LoadingMgr.ShowLoading(true);
            if (uiWnd.PreWndID != UIFlag.none)
            {
                if (!IsShowing(uiWnd.PreWndID))
                {
                    UIWnd preWnd = GetUIWnd(uiWnd.PreWndID);
                    if (preWnd != null)
                    {
                        m_lstShowUIID.Add(preWnd.UIID);
                        preWnd.ReadyShow = false;

                        preWnd.gameObject.SetActive(true);
                        preWnd.OnRefreshWnd();

                        while (!preWnd.ReadyShow)
                        {
                            yield return(null);
                        }
                    }
                }
            }
            else
            {
                if (m_lstShowUIID.Count == 0)
                {
                    itor = ShowWndAsync(m_MainWnd, UIFlag.none, null, UIFlag.none);
                    while (itor.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }

            uiWnd.PreWndID = UIFlag.none;

            ////LoadingMgr.ShowLoading(false);
        }
    }
예제 #8
0
파일: UIMgr.cs 프로젝트: happylays/tbb2
    private void CheckPreUI(UIFlag preID, UIFlag hideID)
    {
        //最多同时显示2个wnd
        UIFlag flag = preID;

        if (flag == UIFlag.none)
        {
            flag = hideID;
        }

        if (flag != UIFlag.none)
        {
            UIWnd preWnd = GetUIWnd(flag);
            if (preWnd != null && preWnd.PreWndID != UIFlag.none)
            {
                if (IsShowing(flag))
                {
                    HideWndSync(preWnd.PreWndID);
                }
            }
        }
    }
예제 #9
0
파일: UIMgr.cs 프로젝트: happylays/tbb2
 public static void RegisterUI(UIWnd uiWnd)
 {
     uimgr.RegisterWnd(uiWnd);
 }
예제 #10
0
파일: UIMgr.cs 프로젝트: happylays/tbb2
 public static void CloseUI(UIWnd uiWnd)
 {
     UICoroutine.uiCoroutine.StartCoroutine(uimgr.CloseWnd(uiWnd));
 }