/// <summary> /// 获取资源对象。 /// </summary> /// <param name="resourceName">资源文件名(不带路径,带后缀)</param> /// <param name="loaded">资源对象加载完成回调</param> public static void GetResource(string resourceName, Action <Object> loaded, Action <float> progress = null) { m_assetMgr.LoadAsset(resourceName, (obj) => { if (obj) { int id = obj.GetInstanceID(); if (!m_resourceDic.ContainsKey(id)) { m_resourceDic.Add(id, resourceName); } } if (loaded != null) { loaded(obj); } }, progress); }
public static void GetNoCacheResource(string resourceName, Action <UnityEngine.Object> loaded, Action <float> progress = null, byte priority = 2) { m_assetMgr.LoadAsset(resourceName, priority, loaded, progress); }
void OnGUI() { if (GUI.Button(new Rect(0, 0, 100, 100), "load npcs")) { var list = (loadAsset as LoadAssetBundlesMainAsset).m_filesDic.Keys.Where(t => t.StartsWith("NPC")).ToList(); var name = list[index]; Mogo.Util.LoggerHelper.Debug(name); loadAsset.LoadInstance(name, (a, b, c) => { loadAsset.Release(name, false); //sw.Stop(); //LoggerHelper.Debug(sw.ElapsedMilliseconds); }); index++; } if (GUI.Button(new Rect(100, 0, 100, 100), "batching")) { StaticBatchingUtility.Combine(tempModel); } fileName = GUI.TextField(new Rect(300, 100, 300, 100), fileName); if (GUI.Button(new Rect(300, 0, 50, 50), "load")) { loadAsset.LoadInstance(fileName, (a, b, c) => { //loadAsset.Release(fileName, false); tempModel = c as GameObject; //sw.Stop(); //LoggerHelper.Debug(sw.ElapsedMilliseconds); }, (progress) => { Debug.Log(progress); }); } if (GUI.Button(new Rect(350, 0, 50, 50), "load UI")) { loadAsset.LoadUIAsset(fileName, (a) => { tempModel = GameObject.Instantiate(a) as GameObject; //loadAsset.Release(fileName, false); //sw.Stop(); //LoggerHelper.Debug(sw.ElapsedMilliseconds); }, null); } if (GUI.Button(new Rect(200, 0, 100, 100), "load res")) { loadAsset.LoadAsset(fileName, (a) => { tempModel = a as GameObject; //sw.Stop(); //LoggerHelper.Debug(sw.ElapsedMilliseconds); }); } if (GUI.Button(new Rect(400, 0, 100, 100), "unload")) { loadAsset.Release(fileName); } if (GUI.Button(new Rect(500, 0, 100, 100), "load scene")) { Application.LoadLevel(Utils.GetFileNameWithoutExtention(fileName)); } if (GUI.Button(new Rect(600, 0, 100, 100), "ClearAll")) { ResourceManager.ClearAll(); } if (GUI.Button(new Rect(600, 100, 100, 100), "UnloadUnused")) { Resources.UnloadUnusedAssets(); } if (GUI.Button(new Rect(600, 200, 100, 100), "GC")) { System.GC.Collect(); } if (GUI.Button(new Rect(400, 300, 100, 100), "set null")) { tempModel = null; } if (GUI.Button(new Rect(500, 300, 100, 100), "Instantiate")) { GameObject.Instantiate(tempModel); } if (GUI.Button(new Rect(600, 300, 100, 100), "tempPref")) { Debug.Log(tempModel); } if (GUI.Button(new Rect(300, 300, 100, 100), "show resources")) { Debug.Log(ResourceManager.resources.Values.ToList().PackList('\n')); } if (GUI.Button(new Rect(200, 300, 100, 100), "Load Meta")) { ResourceManager.LoadMetaOfMeta(() => { Debug.Log("Init META Success"); }, null); } if (GUI.Button(new Rect(100, 300, 100, 100), "GameDataControler Init")) { //LoggerHelper.Debug(FXData.dataMap.Count); //LoggerHelper.Debug(GlobalData.dataMap.Count); Mogo.GameData.GameDataControler.Init(null, () => { }); } }