Esempio n. 1
0
    static bool LoadCheck(LoadInfo info)
    {
        bool canLoadUI = true;

        foreach (AtlasLoader.AtlasStatus st in info.status_.Values)
        {
            if (st != AtlasLoader.AtlasStatus.AS_Loaded)
            {
                canLoadUI = false;
                break;
            }
        }
        if (canLoadUI)
        {
            if (uiRefDic_.ContainsKey(info.name_))
            {
                if (uiRefDic_[info.name_].hasBundle)
                {
                    info.callback_(uiRefDic_[info.name_].Open(), info.pdata_);
                }
                else
                {
                    uiRefDic_[info.name_].Open(info.callback_);
                    AssetLoader.LoadAssetBundle(info.name_, AssetLoader.EAssetType.ASSET_UI, LoadUICallback, info.pdata_);
                }
            }
            else
            {
                UIBundleRef bundleRef = new UIBundleRef();
                bundleRef.Open(info.callback_);
                uiRefDic_.Add(info.name_, bundleRef);
                uiRef4For_.Add(bundleRef);
                AssetLoader.LoadAssetBundle(info.name_, AssetLoader.EAssetType.ASSET_UI, LoadUICallback, info.pdata_);
            }
        }
        return(canLoadUI);
    }
Esempio n. 2
0
    public static bool LoadUI(string assetsName, AssetLoader.AssetLoadCallback CallBack, ParamData paramData)
    {
        LoadInfo info = new LoadInfo();

        info.name_     = assetsName;
        info.callback_ = CallBack;
        info.pdata_    = paramData;
        string[] refAtlas = UIDepedenceData.GetRefAtlas(assetsName);
        if (refAtlas == null)
        {
            //因为MessageBoxPanel界面打开时,处于混沌伊始状态(无数据,无网络) 所以在此写死其所需的图集 囧
            if (assetsName.Equals("MessageBoxPanel") || assetsName.Equals("ItemCell") || assetsName.Equals("BabyCell") || assetsName.Equals("StateCell") || assetsName.Equals("SkillCell"))
            {
                refAtlas = new string[] { "CommomAtlas" }
            }
            ;
            if (assetsName.Equals("Notice"))
            {
                refAtlas = new string[] { "noticeAtlas" }
            }
            ;
            if (assetsName.Equals("LoginPanel"))
            {
                refAtlas = new string[] { "NewLoginAtlas", "CommomAtlas" }
            }
            ;
        }

        if (refAtlas != null)
        {
            info.status_ = new Dictionary <string, AtlasLoader.AtlasStatus>();
            AtlasLoader.AtlasStatus[] refStatus = AtlasLoader.Instance.LoadAtlas(refAtlas);
            for (int i = 0; i < refAtlas.Length; ++i)
            {
                info.status_.Add(refAtlas[i], refStatus[i]);
            }
            if (!LoadCheck(info))
            {
                loadLst.Add(info);
            }
        }
        else
        {
            if (uiRefDic_.ContainsKey(assetsName))
            {
                if (uiRefDic_[assetsName].hasBundle)
                {
                    CallBack(uiRefDic_[assetsName].Open(), paramData);
                }
                else
                {
                    uiRefDic_[assetsName].Open(CallBack);
                    AssetLoader.LoadAssetBundle(assetsName, AssetLoader.EAssetType.ASSET_UI, LoadUICallback, paramData);
                }
            }
            else
            {
                UIBundleRef bundleRef = new UIBundleRef();
                bundleRef.Open(CallBack);
                uiRefDic_.Add(assetsName, bundleRef);
                uiRef4For_.Add(bundleRef);
                AssetLoader.LoadAssetBundle(assetsName, AssetLoader.EAssetType.ASSET_UI, LoadUICallback, paramData);
            }
        }

        return(true);
    }