public virtual IEnumerator LoadUIAsset(UILoadState loadState, UILoadRequest request) { string path = string.Format("ui/{0}.prefab", loadState.TemplateName); var assetLoader = StaticAssetLoader.Load(path); loadState.UIResourceLoader = assetLoader; // 基本不用手工释放的 while (!assetLoader.IsCompleted) { yield return(null); } request.Asset = assetLoader.TheAsset; }
public IEnumerator LoadUIAsset(UILoadState loadState, UILoadRequest request) { #if UNITY_5 string path = string.Format("UI/{0}.prefab", loadState.TemplateName); #else string path = string.Format("UI/{0}_UI", loadState.TemplateName); #endif var assetLoader = StaticAssetLoader.Load(path); loadState.UIResourceLoader = assetLoader; // 基本不用手工释放的 while (!assetLoader.IsCompleted) { yield return(null); } request.Asset = assetLoader.TheAsset; }
IEnumerator TestStaticLoad() { if (staticLoader != null) { Log.Debug("alread exist !"); yield break; } var path = "UI/Login.prefab"; staticLoader = StaticAssetLoader.Load(path); while (!staticLoader.IsCompleted) { yield return null; } Log.Debug("load complete"); }
public IEnumerator LoadUIAsset() { string path = string.Format("UI/{0}.prefab", "WGameLaunch"); var assetLoader = StaticAssetLoader.Load(path); while (!assetLoader.IsCompleted) { yield return(null); } GameObject go = assetLoader.TheAsset as GameObject; GameObject win = GameObject.Instantiate(go); GameObject p = GameObject.Find("UIRootWindow/UIAutoSizer"); win.transform.SetParent(p.transform, false); win.SetActive(true); WGameLaunch wg = win.GetComponent <WGameLaunch>(); wg.StartCoroutine(wg.Launch()); }
private IEnumerator InitSetting() { var assetLoader = StaticAssetLoader.Load("GameSetting" + KEngine.AppEngine.GetConfig("KEngine", "AssetBundleExt"), null); while (!assetLoader.IsCompleted) { yield return(null); } CGameSettingFiles gameSetting = (CGameSettingFiles)assetLoader.TheAsset; for (int i = 0; i < gameSetting.SettingFiles.Length; ++i) { GameSettings[gameSetting.SettingFiles[i]] = gameSetting.SettingContents[i]; } Log.Info("{0} setting files loaded.", GameSettings.Count); Object.Destroy(gameSetting); assetLoader.Release(); LoadFinished = true; }
//private Dictionary<string, StaticAssetLoader> mUIPrefabLoaders = new Dictionary<string, StaticAssetLoader>(); //private List<GameObject> mUIList = new List<GameObject>(); //private Dictionary<string, GameObjectCache> mResCaches = new Dictionary<string, GameObjectCache>(); public void GetUIPrefab(string assetName, Transform parent, LuaTable luaTable, LuaFunction luaCallBack) { if (mResManager == null) { return; } string tmpAssetName = "uiprefab/" + assetName; if (AssetFileLoader.IsEditorLoadAsset) { tmpAssetName = "BuildByFile/" + tmpAssetName + ".prefab"; } StaticAssetLoader.Load(tmpAssetName, (bool isOk, Object resultObj) => { if (!isOk || resultObj == null) { Log.Error("GetUIPrefab is error:{0}", tmpAssetName); return; } GameObject go = resultObj as GameObject; if (go == null) { Log.Error("GetUIPrefab go is null:{0}", tmpAssetName); return; } go.name = assetName; go.layer = LayerMask.NameToLayer("UI"); Vector3 anchorPos = Vector3.zero; Vector2 sizeDel = Vector2.zero; Vector3 scale = Vector3.one; RectTransform rtTr = go.GetComponent <RectTransform>(); if (rtTr != null) { anchorPos = rtTr.anchoredPosition; sizeDel = rtTr.sizeDelta; scale = rtTr.localScale; } go.transform.SetParent(parent, false); if (rtTr != null) { rtTr.anchoredPosition = anchorPos; rtTr.sizeDelta = sizeDel; rtTr.localScale = scale; } UILuaBehaviour tmpBehaviour = Tools.SafeGetComponent <UILuaBehaviour>(go); tmpBehaviour.Init(luaTable); if (luaCallBack != null) { luaCallBack.BeginPCall(); luaCallBack.Push(go); luaCallBack.PCall(); luaCallBack.EndPCall(); luaCallBack.Dispose(); luaCallBack = null; } Debug.Log("CreatePanel::>> " + assetName); }); }