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 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 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); }