NGUI2DRootPanel OnLoadRootUI(string uiName) { float sTime = Time.realtimeSinceStartup; GameObject uiObj = Instantiate(mUIList[uiName]) as GameObject; uiObj.name = uiName; uiObj.SetActive(true); NGUI2DRootPanel ret = uiObj.GetComponent <NGUI2DRootPanel>(); LogSys.Debug("~~~inst ui[" + uiName + "]used:" + (Time.realtimeSinceStartup - sTime).ToString()); return(ret); }
T OnLoadDialog <T>(UIViewType ui, string uiName, string atlasList, PopupDialogType t, Transform parent, string richPath, object[] richPs, PopupDialogView.ButtonEventHandler btnEvent, object[] ps, PopupDialogView.DialogEventHandleer callback) where T : PopupDialogView { float sTime = Time.realtimeSinceStartup; GameObject uiObj = Instantiate(mUIList[uiName]) as GameObject; uiObj.name = uiName; uiObj.SetActive(true); T ret = uiObj.GetComponent <T>(); if (null != ret) { ret.UI类型 = ui; ret.SetWhiteBlockTex(WhiteBlockTex); if (null != callback) { callback(t, ret, parent, richPath, richPs, btnEvent, ps); } bool noNeedAtlas = true; string[] list = atlasList.Split("#".ToCharArray()); List <int> aidList = new List <int>(); for (int i = 0; i < list.Length; ++i) { if (string.IsNullOrEmpty(list[i])) { continue; } if (System.Enum.IsDefined(typeof(UIAtlasType), list[i])) { UIAtlasType at = (UIAtlasType)System.Enum.Parse(typeof(UIAtlasType), list[i]); noNeedAtlas = false; ret.AddRefAtlas(at); aidList.Add((int)at); } } if (noNeedAtlas) { ret.DoReadyShowing(); } else { for (int i = 0; i < aidList.Count; ++i) { StartCoroutine(DoLoadAtlas(aidList[i], ret)); } } } LogSys.Debug("~~~inst ui[" + uiName + "]used:" + (Time.realtimeSinceStartup - sTime).ToString()); return(ret); }
T OnLoadUI <T>(UIViewType ui, string uiName, string atlasList) where T : UIBaseView { float sTime = Time.realtimeSinceStartup; GameObject uiObj = Instantiate(mUIList[uiName]) as GameObject; uiObj.name = uiName; uiObj.SetActive(true); T ret = uiObj.GetComponent <T>(); if (null != ret) { ret.UI类型 = ui; ret.SetWhiteBlockTex(WhiteBlockTex); bool noNeedAtlas = true; string[] list = atlasList.Split("#".ToCharArray()); List <int> aidList = new List <int>(); for (int i = 0; i < list.Length; ++i) { if (string.IsNullOrEmpty(list[i])) { continue; } if (System.Enum.IsDefined(typeof(UIAtlasType), list[i])) { UIAtlasType at = (UIAtlasType)System.Enum.Parse(typeof(UIAtlasType), list[i]); noNeedAtlas = false; ret.AddRefAtlas(at); aidList.Add((int)at); } } if (noNeedAtlas) { ret.DoReadyShowing(); } else { for (int i = 0; i < aidList.Count; ++i) { StartCoroutine(DoLoadAtlas(aidList[i], ret)); } } } LogSys.Debug("~~~inst ui[" + uiName + "]used:" + (Time.realtimeSinceStartup - sTime).ToString()); return(ret); }
//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; }