public static void GetUIInstance(string resourceName, Action <string, int, UnityEngine.Object> loaded, Action <float> progress = null) { m_assetMgr.LoadUIAsset(resourceName, delegate(UnityEngine.Object o) { UnityEngine.Object obj2 = null; int instanceID = -1; if (o != 0) { obj2 = UnityEngine.Object.Instantiate(o); instanceID = obj2.GetInstanceID(); m_gameObjectNameMapping.Add(instanceID, resourceName); } if (loaded != null) { loaded(resourceName, instanceID, obj2); } }, progress); }
public static void GetUIInstance(string resourceName, Action <String, int, Object> loaded, Action <float> progress = null) { //GetInstance(resourceName, loaded); m_assetMgr.LoadUIAsset(resourceName, (o) => { Object go = null; var guid = -1; if (o) { go = GameObject.Instantiate(o); guid = go.GetInstanceID(); m_gameObjectNameMapping.Add(guid, resourceName); } if (loaded != null) { loaded(resourceName, guid, go); } }, 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, () => { }); } }