Exemple #1
0
 private IEnumerator ReDown(LoadHelper loadHelper)
 {
     if (this.data == null)
     {
         while (true)
         {
             if (this.data != null)
             {
                 try
                 {
                     loadHelper.CompleteHandler(this.data);
                 }
                 catch (System.Exception ex)
                 {
                     LoadedData loadedData = this.data as LoadedData;
                     Debug.LogError("加载资源" + loadedData.FilePath + "错误:" + ex.ToString());
                 }
                 break;
             }
             else
             {
                 yield return(null);
             }
         }
     }
     else
     {
         loadHelper.CompleteHandler(data);
     }
 }
Exemple #2
0
        IEnumerator DownAsset(object parm)
        {
            LoadHelper helper = parm as LoadHelper;
            WWW        www    = new WWW("file://" + helper.Url);

            while (true)
            {
                if (www.error != null)
                {
                    Debug.LogError("ImgDownloader DownAsset error:" + helper.Url + www.error);
                    break;
                }
                if (www.isDone)
                {
                    LoadedData data = new LoadedData(www.texture, www.url, helper.OriginalUrl);
                    helper.CompleteHandler(data);
                    if (www != null)
                    {
                        www.Dispose();
                        GameObject.Destroy(this.gameObject);
                    }
                    break;
                }
                else
                {
                    yield return(www);
                }
            }
        }
Exemple #3
0
        IEnumerator DownAsset(object parm)
        {
            this.isDownling = true;
            LoadHelper helper = parm as LoadHelper;
            WWW        www    = new WWW("file://" + helper.Url);

            while (true)
            {
                if (www.isDone)
                {
                    this.isDownling = false;
                    if (www.assetBundle != null)
                    {
                        this.objs = www.assetBundle.LoadAllAssets();
                    }
                    this.data = new LoadedData(this.objs, www.url, helper.OriginalUrl);
                    helper.CompleteHandler(this.data);
                    if (www.assetBundle != null)
                    {
                        www.assetBundle.Unload(false);
                    }
                    break;
                }
                else
                {
                    yield return(www);
                }
            }
        }
Exemple #4
0
        IEnumerator DownAsset(object parm)
        {
            this.isDownling = true;
            LoadHelper helper = parm as LoadHelper;
            WWW        www    = new WWW("file://" + helper.Url);

            while (true)
            {
                if (www.error != null)
                {
                    Debug.LogError("UnityDownloader DownAsset error:" + helper.Url + www.error);
                    break;
                }
                if (www.isDone)
                {
                    try
                    {
                        this.data       = new LoadedData(www, www.url, helper.OriginalUrl);
                        this.isDownling = false;
                        if (helper.IsPublicRes && www.assetBundle != null)
                        {
                            this.objs = www.assetBundle.LoadAllAssets();
                            //if(GlobalDef.IsDev)
                            //{
                            //    Debug.Log("Load Asset:" + helper.Url);
                            //    foreach (object temp in objs)
                            //    {
                            //        Debug.Log("object in Asset in LoadedData:" + temp.ToString());
                            //    }
                            //    Debug.Log("AssetBundle End.");
                            //}
                        }
                        helper.CompleteHandler(this.data);
                    }
                    catch (System.Exception ex)
                    {
                        Debug.LogError("加载资源" + helper.Url + "错误:" + ex.ToString());
                    }
                    finally
                    {
                        //if (!helper.IsPublicRes)
                        //{
                        //    if (www.assetBundle != null)
                        //    {
                        //        www.assetBundle.Unload(false);
                        //    }
                        //    www.Dispose();
                        //    GameObject.Destroy(this.gameObject);
                        //}
                    }
                    break;
                }
                else
                {
                    yield return(www);
                }
            }
        }
Exemple #5
0
        public void StartDown(LoadHelper loadHelper)
        {
            string xmlText = IOHelper.OpenText(loadHelper.Url);

            //if (needDecrupt)
            //{
            //    xmlText = AESManager.AESDecrypt(xmlText);
            //}
            if (loadHelper.CompleteHandler != null)
            {
                loadHelper.CompleteHandler(new LoadedData(xmlText, loadHelper.Url, loadHelper.OriginalUrl));
            }
        }
Exemple #6
0
 private IEnumerator ReDown(LoadHelper loadHelper)
 {
     if (this.data == null)
     {
         while (true)
         {
             if (this.data != null)
             {
                 loadHelper.CompleteHandler(this.data);
                 break;
             }
             else
             {
                 yield return(null);
             }
         }
     }
     else
     {
         loadHelper.CompleteHandler(data);
     }
 }
Exemple #7
0
        IEnumerator DownXML(object parm)
        {
            LoadHelper loadHelper = parm as LoadHelper;
            string     xmlText    = IOHelper.OpenText(loadHelper.Url);

            //if (needDecrupt)
            //{
            //    xmlText = AESManager.AESDecrypt(xmlText);
            //}
            yield return(null);

            Regex           regex           = new Regex("<object .*/>");
            MatchCollection matchCollection = regex.Matches(xmlText);
            string          pattern         = "([A-Za-z0-9_-]*?=\".*?\"){1}";
            int             totalRow        = matchCollection.Count;

            yield return(null);

            for (int i = 0; i < totalRow; i++)
            {
                MatchCollection             mc  = Regex.Matches(matchCollection[i].Value, pattern, RegexOptions.IgnoreCase);
                Dictionary <string, string> dic = new Dictionary <string, string>();
                if (mc.Count > 0)
                {
                    for (int j = 0; j < mc.Count; j++)
                    {
                        string   str      = mc[j].Value.Replace("\"", "");
                        string[] keyValue = str.Split('=');
                        string   key      = keyValue[0];
                        string   value    = keyValue[1];
                        if (dic.ContainsKey(key))
                        {
                            string error = string.Format("{0} has exist key:{1},Row index is:{2}", loadHelper.FileName, key, j);
                            Debug.LogError(error);
                        }
                        else
                        {
                            dic.Add(key, value);
                        }
                    }
                }
                if (loadHelper.XMLResolver != null)
                {
                    try
                    {
                        loadHelper.XMLResolver(dic);
                    }
                    catch (Exception ex)
                    {
                        string info = string.Empty;
                        foreach (KeyValuePair <string, string> keyValue in dic)
                        {
                            info += keyValue.Key + ":" + keyValue.Value + " ";
                        }
                        string error = string.Format("Resolver {0}.xml wrong:row index {1}---{2} exception:{3}", loadHelper.FileName, i, info, ex.ToString());
                        Debug.LogError(error);
                    }
                }
                else
                {
                    Debug.LogError("Resolver" + loadHelper.FileName + ".xml error:XMLResolver is null");
                }
            }
            yield return(null);

            if (loadHelper.CompleteHandler != null)
            {
                loadHelper.CompleteHandler(new LoadedData(xmlText, loadHelper.Url, loadHelper.OriginalUrl));
                GameObject.Destroy(this.gameObject);
            }
        }