private static Bundle _LoadBundleAsyncFile(string bundle_path, string bundle_name) { Bundle bundle; if (_Bundle_Dic.TryGetValue(bundle_name, out bundle)) { return(bundle); } var bundle_request = AssetBundle.LoadFromFileAsync(bundle_path); if (null == bundle_request) { Develop.LogError("Load FAIL" + bundle_path); return(null); } #if AUTO_UNLOAD if (_destroying_coroutine == null) { _destroying_coroutine = Main.Behaviour.StartCoroutine(_UnloadClosedBundle()); } #endif var real = new Bundle_Real(bundle_request, bundle_name); return(real); }
/// <summary> /// 从资源包里加载资源,资源包和资源名相同 /// </summary> /// <param name="asset_name"></param> /// <returns></returns> public static T LoadAssetFromBundle <T>(string asset_name) where T : UObject { string bundle_name = asset_name.ToLower(); Asset <T> asset; #if UNITY_EDITOR if (!UseBundleInEditor) { var br = new Bundle_Real(bundle_name); asset = br.LoadAsset <T>(asset_name); return(asset.Object); } #endif Bundle bundle; if (!_Bundle_Dic.TryGetValue(bundle_name, out bundle)) { Develop.LogError("Can't find bundle :" + bundle_name); return(null); } asset = bundle.LoadAsset <T>(bundle_name); if (asset == null) { Develop.LogError("Can't find asset :" + bundle_name); return(null); } return(asset.Object); }
public static Bundle LoadBundleAsyncWww(string bundle_path, string bundle_name, Hash128 code) { Bundle bundle; if (_Bundle_Dic.TryGetValue(bundle_name, out bundle)) { return(bundle); } var cachedVersion = Caching.IsVersionCached(bundle_path, code); var bundle_www = cachedVersion ? WWW.LoadFromCacheOrDownload(bundle_path, code) : new WWW(bundle_path); #if !AFTER_CHECK var after_cacheAble = Caching.IsVersionCached(bundle_path, code); if (cachedVersion != after_cacheAble) { Develop.LogError(cachedVersion + "Cached:" + bundle_path); } #endif if (!string.IsNullOrEmpty(bundle_www.error)) { Develop.LogError("Load FAIL" + bundle_path + ":" + bundle_www.error); } var real = new Bundle_Real(bundle_www, bundle_name); _Bundle_Dic.Add(bundle_name, real); return(real); }