예제 #1
0
 /// <summary>
 /// 关闭系统UI
 /// </summary>
 /// <param name="type"></param>
 public void CloseSystemUI(GameResources.SystemUIType type = GameResources.SystemUIType.NULL, LoadManager.CallBack call = null)
 {
     //如果当前没有页面显示,则直接返回
     if (SystemList.Count <= 0)
     {
         return;
     }
     //如果直接关闭当前最前一层ui
     if (type == GameResources.SystemUIType.NULL)
     {
         GameObject go;
         if (!SystemUICache.TryGetValue(SystemList[SystemList.Count - 1], out go))
         {
             return;
         }
         go.SetActive(false);
         SystemList.RemoveAt(SystemList.Count - 1);
     }
     else
     {
         //关闭指定的UI界面
         GameObject go;
         if (!SystemUICache.TryGetValue(type, out go))
         {
             return;
         }
         go.SetActive(false);
         //将UI界面从队列中剔除
         for (int i = 0; i < SystemList.Count; i++)
         {
             if (SystemList [i] == type)
             {
                 SystemList.RemoveAt(i);
                 break;
             }
         }
     }
     if (call != null)
     {
         call();
     }
 }
예제 #2
0
    /// <summary>
    /// 加载系统UI
    /// </summary>
    /// <param name="type"></param>
    /// <param name="call"></param>
    public void LoadSyStemUI(GameResources.SystemUIType type, LoadManager.CallBack call = null)
    {
        //设置父对象为system
        Transform  tfp = transform.parent.FindChild("system");
        GameObject go;

        //尝试获取缓存中是否含有加载对象
        if (!SystemUICache.TryGetValue(type, out go))
        {
            //如果没有,则加载生成之后,将页面对象添加到缓存中
            string path = GameResources.UIResourcesPath + GameData.Instance.SystemUI[type];
            go = GameApp.Instance.ResourcesManagerScript.LoadInstantiateGameObject(path, tfp, Vector3.zero);
            SystemUICache.Add(type, go);
        }
        else
        {
            //否则直接将该页面调至最前并显示出来
            go.transform.SetAsLastSibling();
            go.SetActive(true);
        }
        //如果当前队列中该页面已经显示,则在队列中剔除
        for (int i = 0; i < SystemList.Count; i++)
        {
            if (SystemList [i] == type)
            {
                SystemList.RemoveAt(i);
                break;
            }
        }
        //将页面显示添加在队列最后一位
        SystemList.Add(type);
        if (call != null)
        {
            call();
        }
    }