public static bool ParseLuaAsset(string url) { bool result = false; WWW www = AssetPool.GetWww(url); if (www != null) { try { UnityEngine.Object[] array = www.assetBundle.LoadAll(typeof(TextAsset)); for (int i = 0; i < array.Length; i++) { UnityEngine.Object @object = array[i]; AssetPool.AddAsset(@object.name, @object, 999, true); } www.assetBundle.Unload(false); result = true; } catch (Exception ex) { string text = "资源解析失败 " + url + "\n" + ex.Message; Pandora.Instance.ReportError(text, 10217582); Logger.LogError(text); LocalDirectoryHelper.DeleteAssetByUrl(url); } AssetPool.DisposeWww(url); } return(result); }
public static bool ParseImageAsset(string url, bool isCacheInMemory) { bool result = false; WWW www = AssetPool.GetWww(url); if (www != null) { try { Texture2D textureNonReadable = www.textureNonReadable; textureNonReadable.name = url; AssetPool.AddAsset(url, textureNonReadable, 0, isCacheInMemory); result = true; } catch (Exception ex) { string text = "资源解析失败: " + url + "\n" + ex.Message; Pandora.Instance.ReportError(text, 10217582); Logger.LogError(text); LocalDirectoryHelper.DeleteAssetByUrl(url); } AssetPool.DisposeWww(url); } return(result); }
public static List <string> DeleteZeroReferenceAsset() { AssetPool._deletedKeyList.Clear(); AssetPool.DeleteZeroReferenceAsset(AssetPool._strongAssetDict); AssetPool.DeleteZeroReferenceAsset(AssetPool._weakAssetDict); return(AssetPool._deletedKeyList); }
private static void OnLoadImage(string cacheUrl, Action <Texture2D> callback) { Texture2D obj = AssetPool.GetAsset(cacheUrl) as Texture2D; if (callback != null) { callback(obj); } }
private static void OnLoadAssetBundle(string cacheUrl, Action <AssetBundle> callback) { AssetBundle obj = AssetPool.GetAsset(cacheUrl) as AssetBundle; if (callback != null) { callback(obj); } }
protected override bool HandleLoadedContent(string url, WWW www) { if (Pandora.Instance.IsDebug) { Logger.Log("<color=#00ff00>资源从本地加载到内存成功</color>, url: " + url); } AssetPool.AddWww(url, www); return(AssetPool.ParseAsset(url, this._assetConfigDict[url])); }
public static void ReleaseAsset(string key) { if (!AssetPool.IsInStrongDict(key)) { return; } AssetPool.Asset asset = AssetPool._strongAssetDict[key]; asset.ReferenceCount--; }
public static bool ParseAssetBundle(string url) { WWW www = AssetPool.GetWww(url); if (www != null) { AssetPool.AddAsset(url, www.assetBundle, 0, false); AssetPool.DisposeWww(url); } return(true); }
public static void ReleaseProgramAsset(RemoteConfig.AssetInfo assetInfo) { if (CacheManager.IsProgramAssetExists(assetInfo.name, assetInfo.md5)) { string cachedProgramAssetUrl = CacheManager.GetCachedProgramAssetUrl(assetInfo.url); AssetPool.ReleaseAsset(cachedProgramAssetUrl); } else { AssetPool.ReleaseAsset(assetInfo.url); } }
public static void ReleaseAsset(string url) { if (CacheManager.IsAssetExists(url)) { string cachedAssetUrl = CacheManager.GetCachedAssetUrl(url); AssetPool.ReleaseAsset(cachedAssetUrl); } else { AssetPool.ReleaseAsset(url); } }
private static void OnLoadPrefab(string cacheUrl, Action <GameObject> callback) { GameObject gameObject = AssetPool.GetAsset(cacheUrl) as GameObject; GameObject obj = null; if (gameObject != null) { obj = (UnityEngine.Object.Instantiate(gameObject) as GameObject); } if (callback != null) { callback(obj); } }
public static UnityEngine.Object GetAsset(string key) { if (AssetPool.IsInStrongDict(key)) { AssetPool.Asset asset = AssetPool._strongAssetDict[key]; asset.ReferenceCount++; return(asset.Object); } if (AssetPool.IsInWeakDict(key)) { AssetPool.Asset asset2 = AssetPool._weakAssetDict[key]; return(asset2.Object); } return(null); }
public static byte[] GetLuaBytes(string name) { string key = name + ".lua"; UnityEngine.Object @object = AssetPool.GetAsset(key); if (@object != null) { return((@object as TextAsset).bytes); } @object = AssetPool.FindLuaAsset(key); if (@object != null) { return((@object as TextAsset).bytes); } return(null); }
public static void GetImage(string url, bool isCacheInMemory, Action <Texture2D> callback) { string cachedAssetUrl = CacheManager.GetCachedAssetUrl(url); if (AssetPool.HasAsset(cachedAssetUrl)) { AssetManager.OnLoadImage(cachedAssetUrl, callback); } else if (CacheManager.IsAssetExists(url)) { AssetManager.LoadImage(cachedAssetUrl, isCacheInMemory, callback); } else { CacheManager.LoadAsset(url, delegate(string pUrl) { AssetManager.OnCacheLoadImage(pUrl, isCacheInMemory, callback); }); } }
public static void GetAssetBundle(string url, Action <AssetBundle> callback) { string cachedAssetUrl = CacheManager.GetCachedAssetUrl(url); if (AssetPool.HasAsset(cachedAssetUrl)) { AssetManager.OnLoadAssetBundle(cachedAssetUrl, callback); } else if (CacheManager.IsAssetExists(url)) { AssetManager.LoadAssetBundle(cachedAssetUrl, callback); } else { CacheManager.LoadAsset(url, delegate(string pUrl) { AssetManager.OnCacheLoadAssetBundle(pUrl, callback); }); } }
public static void GetGameObject(string url, bool isCacheInMemory, Action <GameObject> callback) { string cachedAssetUrl = CacheManager.GetCachedAssetUrl(url); if (AssetPool.HasAsset(cachedAssetUrl)) { AssetManager.OnLoadPrefab(cachedAssetUrl, callback); } else if (CacheManager.IsAssetExists(url)) { AssetManager.LoadPrefab(cachedAssetUrl, isCacheInMemory, callback); } else { CacheManager.LoadAsset(url, delegate(string pUrl) { AssetManager.LoadPrefab(pUrl, isCacheInMemory, callback); }); } }
public static bool ParseAsset(string url, AssetConfig config) { switch (config.type) { case AssetType.Lua: return(AssetPool.ParseLuaAsset(url)); case AssetType.Prefab: return(AssetPool.ParsePrefabAsset(url, config.isCacheInMemory)); case AssetType.Image: return(AssetPool.ParseImageAsset(url, config.isCacheInMemory)); case AssetType.Assetbundle: return(AssetPool.ParseAssetBundle(url)); default: return(false); } }
public static void GetPanelGameObject(RemoteConfig.AssetInfo assetInfo, Action <GameObject> callback) { string cachedProgramAssetUrl = CacheManager.GetCachedProgramAssetUrl(assetInfo.url); if (AssetPool.HasAsset(cachedProgramAssetUrl)) { AssetManager.OnLoadPrefab(cachedProgramAssetUrl, callback); } else if (CacheManager.IsProgramAssetExists(assetInfo.name, assetInfo.md5)) { AssetManager.LoadProgramPrefab(assetInfo, true, callback); } else { CacheManager.DeleteUnmatchCacheFile(assetInfo.name); CacheManager.LoadAsset(assetInfo.url, delegate(string pUrl) { AssetManager.LoadProgramPrefab(assetInfo, true, callback); }); } }
public static bool ParsePrefabAsset(string url, bool isCacheInMemory) { bool result = false; WWW www = AssetPool.GetWww(url); if (www != null) { try { UnityEngine.Object[] array = new UnityEngine.Object[] { www.assetBundle.mainAsset }; if (array.Length > 1) { throw new Exception("资源打包不符合规范,一个AssetBundle中只能有一个Prefab, " + url); } for (int i = 0; i < array.Length; i++) { UnityEngine.Object obj = array[i]; AssetPool.AddAsset(url, obj, 0, isCacheInMemory); } www.assetBundle.Unload(false); result = true; } catch (Exception ex) { string text = "资源解析失败: " + url + "\n" + ex.Message; Pandora.Instance.ReportError(text, 10217582); Logger.LogError(text); LocalDirectoryHelper.DeleteAssetByUrl(url); } AssetPool.DisposeWww(url); } return(result); }
public static Dictionary <string, int> GetAssetReferenceCountDict() { return(AssetPool.GetAssetReferenceCountDict()); }
public static void Clear() { AssetManager._assetLoader.Clear(); CacheManager.Clear(); AssetPool.Clear(); }
public static UnityEngine.Object GetAsset(string url) { string cachedAssetUrl = CacheManager.GetCachedAssetUrl(url); return(AssetPool.GetAsset(cachedAssetUrl)); }
public static bool HasAsset(string key) { return(AssetPool.IsInStrongDict(key) || AssetPool.IsInWeakDict(key)); }