public async Task <AssetBundle> LoadAssetBundle(string bundlePath) { AssetBundle assetBundle = null; if (cacheAssetBundleDic.TryGetValue(bundlePath, out assetBundle)) { return(assetBundle); } else { try { //load dependences await LoadAssetBundleDependences(manifest.GetAllDependencies(bundlePath)); var loader = CreateAssetLoader <AssetBundle>(); assetBundle = await loader.LoadAssetBundle(bundlePath); RecycleAssetLoader(loader); assetBundleRefCountDic.Add(bundlePath, 1); cacheAssetBundleDic.Add(bundlePath, assetBundle); } catch (System.Exception e) { ZLog.Debug(e.Message + "=====" + e.StackTrace); } return(assetBundle); } }
private async void Start() { ZLog.Debug("Test--------------------"); var stopwatch = new Stopwatch(); stopwatch.Start(); //await ResMgr.Instance.Init(); //await ResMgr.Instance.LoadAssetBundle("com"); // ZLog.Debug(bundle.name); //var cube3 = await ResMgr.Instance.LoadAsset<GameObject>(new AssetId("cube3", "Cube3")); //var cube2 = await ResMgr.Instance.LoadAsset<GameObject>(new AssetId("cube2", "Cube2")); //GameObject.Instantiate(cube3, Vector3.zero, Quaternion.identity); //GameObject.Instantiate(cube2, Vector3.up, Quaternion.identity); //await new AsyncWaitFrame(1); //StartCoroutine(TestIE()); // ZLog.Debug(Time.deltaTime*30); await new AsyncWaitFrame(30); stopwatch.Stop(); ZLog.Debug(stopwatch.ElapsedMilliseconds); stopwatch.Restart(); await new AsyncWaitFrame(30); stopwatch.Stop(); ZLog.Debug(stopwatch.ElapsedMilliseconds); stopwatch.Restart(); await new AsyncWaitFrame(30); stopwatch.Stop(); ZLog.Debug(stopwatch.ElapsedMilliseconds); stopwatch.Restart(); await new AsyncWaitFrame(30); stopwatch.Stop(); ZLog.Debug(stopwatch.ElapsedMilliseconds); }
public static void PrintMsgDic() { ZLog.Debug("\t\t\t=== MESSENGER PrintEventTable ==="); foreach (KeyValuePair <uint, Delegate> pair in msgHandlerDic) { ZLog.Debug("\t\t\t" + pair.Key + "\t\t" + pair.Value); } ZLog.Debug("\n"); }
private IEnumerator TestIE() { var stopwatch = new Stopwatch(); stopwatch.Start(); for (var i = 0; i < 30; i++) { yield return(null); } stopwatch.Stop(); ZLog.Debug(stopwatch.ElapsedMilliseconds); }
public async Task <T> LoadAsset <T>(AssetId assetId) where T : Object { Object o = null; if (cacheResDic.TryGetValue(assetId, out o)) { return(o as T); } // #if UNITY_EDITOR // LoadAssetFromLocal<T>(assetId, onFinished); // #else AssetBundle bundle = null; T asset = null; try { if (cacheAssetBundleDic.TryGetValue(assetId.BundleId, out bundle)) { asset = await LoadAssetFromBundle <T>(assetId, bundle); } else { bundle = await LoadAssetBundle(assetId.BundleId); asset = await LoadAssetFromBundle <T>(assetId, bundle); } } catch (System.Exception e) { ZLog.Debug(e.Message + "=====" + e.StackTrace); } return(asset); //#endif }