public IEnumerator LoadAssetBundleAssetAsync(string path, AssetBundleAssetProxy proxy, Action <float> progress) { UnityObject asset = null; var exception = PoolMgr.singleton.GetCsharpObject <GameException>(); #if UNITY_EDITOR asset = UnityEditor.AssetDatabase.LoadAssetAtPath <UnityObject>(path); #endif //先等一帧; yield return(CoroutineMgr.WaitForEndOfFrame); if (proxy != null) { proxy.OnFinish(asset); } else { exception.AppendMsg($"[ResourceMgr]LoadFromFileAsync proxy is null:{path}."); } if (exception.IsActive) { throw exception; } else { PoolMgr.singleton.ReleaseCsharpObject(exception); } }
public IEnumerator LoadAssetBundleAssetAsync(string path, AssetBundleAssetProxy proxy, Action <float> progress) { AssetBundle assetBundle = null; var exception = PoolMgr.singleton.GetCsharpObject <GameException>(); //此处加载占0.8; var itor = AssetBundleMgr.singleton.LoadFromFileAsync(path, bundle => { assetBundle = bundle; }, progress); while (itor.MoveNext()) { yield return(CoroutineMgr.WaitForEndOfFrame); } var name = Path.GetFileNameWithoutExtension(path); var request = assetBundle.LoadAssetAsync(name); //此处加载占0.2; while (request.progress < 0.99f) { progress?.Invoke(singleton.LOAD_BUNDLE_PRECENT + singleton.LOAD_ASSET_PRECENT * request.progress); yield return(CoroutineMgr.WaitForEndOfFrame); } while (!request.isDone) { yield return(CoroutineMgr.WaitForEndOfFrame); } if (null == request.asset) { AssetBundleMgr.singleton.UnloadAsset(path, null); exception.AppendMsg($"[ResourceMgr]LoadFromFileAsync load asset:{path} failure."); } else { AssetBundleMgr.singleton.AddAssetRef(path, request.asset); } //先等一帧; yield return(CoroutineMgr.WaitForEndOfFrame); if (proxy != null) { proxy.OnFinish(request.asset); } else { exception.AppendMsg($"[ResourceMgr]LoadFromFileAsync proxy is null:{path}."); } if (exception.IsActive) { throw exception; } else { PoolMgr.singleton.ReleaseCsharpObject(exception); } }