/// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="assetType">Type of the asset.</param>
        /// <param name="assets">The assets.</param>
        public WebAssetItemCollectionBuilder(WebAssetType assetType, WebAssetItemCollection assets)
        {
            if (assetType == WebAssetType.None)
            {
                throw new ArgumentException("None is only used for internal purpose", "assets");
            }

            _assetType = assetType;
            _assets    = assets;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WebAssetItemCollectionBuilder"/> class.
        /// </summary>
        /// <param name="assetType">Type of the asset.</param>
        /// <param name="assets">The assets.</param>
        public WebAssetItemCollectionBuilder(WebAssetType assetType, WebAssetItemCollection assets)
        {
            if (assetType == WebAssetType.None)
            {
                throw new ArgumentException(TextResource.NoneIsOnlyUsedForInternalPurpose, "assetType");
            }

            Guard.IsNotNull(assets, "assets");

            this.assetType = assetType;
            this.assets = assets;
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebAssetCollectionBuilder"/> class.
        /// </summary>
        /// <param name="assetType">Type of the asset.</param>
        /// <param name="assets">The assets.</param>
        public WebAssetCollectionBuilder(WebAssetType assetType, WebAssetCollection assets)
        {
            if (assetType == WebAssetType.None)
            {
                throw new ArgumentException(TextResource.NoneIsOnlyUsedForInternalPurpose, "assetType");
            }

            Guard.IsNotNull(assets, "assets");

            this.assetType = assetType;
            this.assets    = assets;
        }
示例#4
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;
        }
示例#5
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));
 }
示例#6
0
 public void Fetch(string url, WebAssetType assetType, int version, OnFetchDelegate onFetch, object cookie)
 {
     this.Fetch(url, null, null, assetType, version, onFetch, cookie);
 }