IEnumerator DoLoadAtlas(UIAtlas atlas, int aid, string atlasResName) { while (mUIAtlasLoading) { yield return(new WaitForFixedUpdate()); } mUIAtlasLoading = true; if (null == atlas.texture) { WWW ui = StreamAssetHelper.LoadAsset(StreamAssetRoot.UIATLASTEX_ROOT, atlasResName + ".tex", 1); ui.threadPriority = ThreadPriority.High; yield return(ui); AssetBundle ab = ui.assetBundle; if (null == atlas.texture) { if (!string.IsNullOrEmpty(ui.error)) { PopupDialogView.PopupAB(PopupDialogType.Confirm, SharedResources.Inst.UIPopup, "错误", ui.error); Debug.LogError(ui.error); } else { if (null == ab) { string error = "图包:" + atlas.name + "[" + atlasResName + "]的assetBundle为空!"; PopupDialogView.PopupAB(PopupDialogType.Confirm, SharedResources.Inst.UIPopup, "错误", error); Debug.LogError(error); } else { //float sTime = Time.realtimeSinceStartup; atlas.spriteMaterial.mainTexture = ab.mainAsset as Texture2D; ab.Unload(false); //LogSys.Debug("~~~inst atlas[" + atlasObj.name + "]used:" + (Time.realtimeSinceStartup - sTime).ToString()); //mAtlasRefCounts.Add(atlas.name, 0); LogSys.Debug("成功载入图包:" + atlas.name); } } } else if (null != ab) { ab.Unload(false); } ui.Dispose(); } if (!mAtlasRefCounts.ContainsKey(aid)) { mAtlasRefCounts.Add(aid, 0); } mUIAtlasLoading = false; }
//IEnumerator DoLoadFont(UIHlp.动态字体类型 t, Object lbl) //{ // string fontName = t.ToString(); // if (!mFontList.ContainsKey(fontName)) // { // string fontResName = LogicModel.GetResName(ResourceType.Font, fontName); // if (string.IsNullOrEmpty(fontResName)) // Debug.LogError("找不到字体[" + t.ToString() + "]对应的资源!"); // else // yield return StartCoroutine(DoLoadFont(fontName, fontResName)); // } // if (null != lbl) // { // //lblEx.OnFontLoaded(fontName, mFontList[fontName]); // } //} IEnumerator DoLoadTexture(string path) { while (mTextureLoading) { yield return(new WaitForFixedUpdate()); } mTextureLoading = true; if (!mTextureList.ContainsKey(path)) { WWW file = StreamAssetHelper.LoadAsset(StreamAssetRoot.TEXTURE_ROOT, path); file.threadPriority = ThreadPriority.High; yield return(file); if (!string.IsNullOrEmpty(file.error)) { PopupDialogView.PopupAB(PopupDialogType.Confirm, SharedResources.Inst.UIPopup, "错误", file.error); Debug.LogError(file.error); } else { AssetBundle ab = file.assetBundle; Texture2D tex = file.texture; if (null == tex) { string error = "贴图" + path + "的texture为空!"; PopupDialogView.PopupAB(PopupDialogType.Confirm, SharedResources.Inst.UIPopup, "错误", error); Debug.LogError(error); } else { mTextureList.Add(path, new TwoData <Texture, int>(tex, 0)); if (null != ab) { ab.Unload(false); } LogSys.Debug("成功载入贴图:" + path); } } file.Dispose(); } mTextureLoading = false; }