Пример #1
0
    // 卸载UI界面
    public void ReleaseUI(UIType _type)
    {
        // UI 是否已注册
        if (!m_UIDict.ContainsKey(_type))
        {
            throw new Exception("ui has not register!");
        }

        if (m_LoadedUI.ContainsKey(_type))
        {
            UIInfo uiInfo = m_LoadedUI[_type];
            string uiPath = ResourceConfig.GetUIPath(uiInfo.path);
            ResourceManager.Instance.UnLoadAll(uiPath);
            m_LoadedUI.Remove(_type);
        }
    }
Пример #2
0
    // 加载UI
    private void LoadUI(UIType _type, Action <UIInfo> cb)
    {
        // 加载UI资源并实例化GameObject
        UIInfo uiInfo = m_UIDict[_type];
        string uiPath = ResourceConfig.GetUIPath(uiInfo.path);

        UnityEngine.Object obj = ResourceManager.Instance.Load(uiPath);
        GameObject         go  = (GameObject)Instantiate(obj);

        uiInfo.ui        = go.GetComponent <UIBase>();
        uiInfo.ui.UIInfo = uiInfo;

        // 缓存界面
        m_LoadedUI.Add(_type, uiInfo);

        // 回调
        if (cb != null)
        {
            cb(uiInfo);
        }
    }