Exemplo n.º 1
0
 public bool CheckMenuLayerVisiable()
 {
     foreach (var window in m_loadedWindow)
     {
         if (!window.Value.Is3D())
         {
             UIBase2D uiwindow = window.Value as UIBase2D;
             if (uiwindow.Getlayer() == UGUI_LAYER.MENU)
             {
                 if (uiwindow.IsVisible())
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 2
0
    public void Release(IWindowBase window)
    {
        if (window == null)
        {
            return;
        }
        UIBase2D uibase2D = window as UIBase2D;

        uibase2D.OnRelease();
        List <UIBase2D> listwindow = null;

        m_openMap.TryGetValue(uibase2D.Getlayer(), out listwindow);
        if (listwindow != null)
        {
            listwindow.Remove(uibase2D);
        }
        Destroy(uibase2D.gameObject);
    }
Exemplo n.º 3
0
    public IWindowBase Open(UGUI_TYPE uiType, UGUI_TYPE parentUIType = UGUI_TYPE._BEGIN)
    {
        IWindowBase uiwindow;

        m_loadedWindow.TryGetValue(uiType, out uiwindow);
        if (uiwindow == null)
        {
            uiwindow = CreateWindow(uiType);
            if (uiwindow == null)
            {
                return(null);
            }
            if (!uiwindow.Is3D())
            {
                m_root2D.Add(uiwindow);
            }
        }
        else
        {
            m_root2D.SortChildLayer(uiwindow); //还未销毁,就重新排序
        }

        uiwindow.Open();
        if (!uiwindow.Is3D())
        {
            UIBase2D uibase2D = uiwindow as UIBase2D;
            if (uibase2D.Getlayer() == UGUI_LAYER.MENU)
            {
                SetMainUIActive(false);
            }
        }
        HideMainCamera();
        if (parentUIType != UGUI_TYPE._BEGIN)
        {
            ParentUIStruct parentUI = new ParentUIStruct();
            parentUI.ParentUI = parentUIType;
            parentUI.ChildUI  = uiType;
            m_ParentUI.Push(parentUI);
        }
        return(uiwindow);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 对某个子UI重新排序
    /// </summary>
    /// <param name="window"></param>
    public void SortChildLayer(IWindowBase window)
    {
        UIBase2D uibase2D = window as UIBase2D;

        if (uibase2D == null)
        {
            return;
        }

        UGUI_LAYER      layer       = uibase2D.Getlayer();
        List <UIBase2D> listWindows = null;

        if (!m_openMap.TryGetValue(layer, out listWindows))
        {
            listWindows = new List <UIBase2D>();
            m_openMap.Add(layer, listWindows);
        }
        listWindows.Remove(uibase2D);
        listWindows.Add(uibase2D);
        SortLayer(layer, listWindows);
    }
Exemplo n.º 5
0
 /// <summary>
 /// 打开全屏的界面时,可以隐藏掉主界面层的UI, 一个优化点,不要直接setactive,会导致重建,可以关闭canvas和raycast。
 /// </summary>
 public void SetMainUIActive(bool show)
 {
     foreach (var window in m_loadedWindow)
     {
         if (!window.Value.Is3D())
         {
             UIBase2D uiwindow = window.Value as UIBase2D;
             if (uiwindow.Getlayer() == UGUI_LAYER.ROOT)
             {
                 int layer = LayerMask.NameToLayer("UGUI");
                 CommonFunc.SetLayer(uiwindow.gameObject, layer);
                 uiwindow.gameObject.GetComponent <Canvas>().enabled           = show;
                 uiwindow.gameObject.GetComponent <GraphicRaycaster>().enabled = show;
                 GraphicRaycaster[] rays = uiwindow.gameObject.GetComponentsInChildren <GraphicRaycaster>();
                 for (int i = 0; i < rays.Length; i++)
                 {
                     rays[i].enabled = show;
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
    public void Add(IWindowBase window)
    {
        if (window == null)
        {
            return;
        }
        UIBase2D uibase2D = window as UIBase2D;

        uibase2D.Initialize();
        uibase2D.transform.SetParent(transform, false);

        UGUI_LAYER      layer       = uibase2D.Getlayer();
        List <UIBase2D> listWindows = null;

        if (!m_openMap.TryGetValue(layer, out listWindows))
        {
            listWindows = new List <UIBase2D>();
            m_openMap.Add(layer, listWindows);
        }
        listWindows.Add(uibase2D);
        SortLayer(layer, listWindows);
    }