Esempio n. 1
0
 public void Fetch(string url, Dictionary <string, string> requestFields, Dictionary <string, string> headers, WebAssetType assetType, int version, OnFetchDelegate onFetch, object cookie)
 {
     byte[] formData = null;
     if (requestFields != null)
     {
         WWWForm wWWForm = new WWWForm();
         foreach (KeyValuePair <string, string> current in requestFields)
         {
             wWWForm.AddField(current.Key, current.Value);
         }
         formData = wWWForm.data;
     }
     this.coroutineScript.StartCoroutine(this.FetchCoroutine(url, formData, headers, assetType, version, onFetch, cookie));
 }
Esempio n. 2
0
        private IEnumerator FetchCoroutine(string url, byte[] formData, Dictionary <string, string> headers, WebAssetType assetType, int version, OnFetchDelegate onFetch, object cookie)
        {
            object obj  = null;
            string text = null;

            if (string.IsNullOrEmpty(url))
            {
                text = "Invalid url";
            }
            else
            {
                while (this.wwws.Count >= 20)
                {
                    yield return(null);
                }
                WWW wWW;
                if (version != 0 && assetType == WebAssetType.Bundle)
                {
                    wWW = WWW.LoadFromCacheOrDownload(url, version);
                }
                else if (formData == null && headers == null)
                {
                    wWW = new WWW(url);
                }
                else
                {
                    wWW = new WWW(url, formData, headers);
                }
                this.wwws.Add(wWW);
                yield return(wWW);

                if (!this.wwws.Remove(wWW))
                {
                    goto IL_25B;
                }
                text = wWW.error;
                if (string.IsNullOrEmpty(text))
                {
                    if (assetType != WebAssetType.StandaloneText)
                    {
                        if (assetType != WebAssetType.StandaloneBinary)
                        {
                            if (assetType != WebAssetType.Bundle)
                            {
                                obj = null;
                            }
                            else
                            {
                                obj = wWW.assetBundle;
                            }
                        }
                        else
                        {
                            obj = wWW.bytes;
                        }
                    }
                    else
                    {
                        obj = wWW.text;
                    }
                }
                wWW.Dispose();
            }
            if (object.ReferenceEquals(obj, null))
            {
                Service.Logger.WarnFormat("Failed to fetch asset {0} ({1})", new object[]
                {
                    url,
                    text
                });
            }
            onFetch(obj, text, cookie);
IL_25B:
            yield break;
        }
Esempio n. 3
0
 public void Fetch(string url, WebAssetType assetType, int version, OnFetchDelegate onFetch, object cookie)
 {
     this.Fetch(url, null, null, assetType, version, onFetch, cookie);
 }