Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }