Ejemplo n.º 1
0
        /// <summary>
        /// Downloads the asset bundle list.
        /// </summary>
        /// <returns>The asset bundle list.</returns>
        /// <param name="url">URL.</param>
        /// <param name="done">Done.</param>
        /// <param name="failed">Failed.</param>
        /// <param name="timeoutSec">Timeout sec.</param>
        public IEnumerator DownloadAssetBundleList(string url, Action <AssetBundleList> done, Action <int, string, AutoyaStatus> failed, double timeoutSec = 0)
        {
            var connectionId = AssetBundlesSettings.ASSETBUNDLES_ASSETBUNDLELIST_PREFIX + Guid.NewGuid().ToString();
            var reqHeader    = assetBundleGetRequestHeaderDelegate(url, new Dictionary <string, string>());

            AssetBundleList         assetBundleList       = null;
            Action <string, object> listDonwloadSucceeded = (conId, listData) => {
                var listString = listData as string;
                assetBundleList = JsonUtility.FromJson <AssetBundleList>(listString);

                done(assetBundleList);
            };

            Action <string, int, string, AutoyaStatus> listDownloadFailed = (conId, code, reason, autoyaStatus) => {
                failed(code, reason, autoyaStatus);
            };

            var downloadCoroutine = DownloadAssetBundleListCoroutine(
                connectionId,
                reqHeader,
                url,
                (conId, code, responseHeader, listData) => {
                httpResponseHandlingDelegate(connectionId, responseHeader, code, listData, string.Empty, listDonwloadSucceeded, listDownloadFailed);
            },
                (conId, code, reason, responseHeader) => {
                httpResponseHandlingDelegate(connectionId, responseHeader, code, string.Empty, reason, listDonwloadSucceeded, listDownloadFailed);
            },
                timeoutSec
                );

            while (downloadCoroutine.MoveNext())
            {
                yield return(null);
            }
        }
Ejemplo n.º 2
0
            /**
             *  update list then regenerate assetName-bundleNameDict.
             */
            public Dictionary <string, string> Update(AssetBundleList newList)
            {
                storage[newList.identity] = newList;

                // reset bundleName - downloadableUrl dictionary.
                {
                    bundleNameAndDownloadUrlDict.Clear();

                    foreach (var bundleList in storage.Values)
                    {
                        var bundleDownloadUrl = OnBundleDownloadUrlRequired(bundleList.identity);
                        foreach (var assetBundleInfo in bundleList.assetBundles)
                        {
                            bundleNameAndDownloadUrlDict[assetBundleInfo.bundleName] = bundleDownloadUrl;
                        }
                    }
                }

                var assetNamesAndAssetBundleNamesDict = new Dictionary <string, string>();
                var wholeAssetBundleInfos             = storage.Values.SelectMany(s => s.assetBundles).ToList();

                foreach (var assetBundle in wholeAssetBundleInfos)
                {
                    var bundleName = assetBundle.bundleName;
                    foreach (var assetName in assetBundle.assetNames)
                    {
                        assetNamesAndAssetBundleNamesDict[assetName] = bundleName;
                    }
                }

                return(assetNamesAndAssetBundleNamesDict);
            }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:AutoyaFramework.AssetBundles.AssetBundleList"/> class.
 /// </summary>
 /// <param name="baseList">Base list.</param>
 public AssetBundleList(AssetBundleList baseList)
 {
     this.target       = baseList.target;
     this.version      = baseList.version;
     this.assetBundles = new AssetBundleInfo[baseList.assetBundles.Length];
     for (var i = 0; i < assetBundles.Length; i++)
     {
         assetBundles[i] = new AssetBundleInfo(baseList.assetBundles[i]);
     }
 }
Ejemplo n.º 4
0
        /**
         *      update assetbundle list and basePath.
         */
        public void UpdateList(string basePath, AssetBundleList newList, Action <string[], string> updatedOnMemoryAssetNameAndBundleName)
        {
            this.assetDownloadBasePath = basePath;

            /*
             *      check updated asset -> notify with asset names.
             */
            var loadedBundleNames = assetBundleDict.Keys.ToArray();

            if (loadedBundleNames.Any())
            {
                // current.
                var bundleNameHashDict = this.list.assetBundles
                                         .Where(b => loadedBundleNames.Contains(b.bundleName))
                                         .ToDictionary(i => i.bundleName, i => i.hash);

                // new.
                var newBundleNameHashDict = newList.assetBundles
                                            .Where(b => loadedBundleNames.Contains(b.bundleName))
                                            .ToDictionary(i => i.bundleName, i => i.hash);

                foreach (var loadedBundleName in loadedBundleNames)
                {
                    if (!newBundleNameHashDict.ContainsKey(loadedBundleName))
                    {
                        continue;
                    }

                    var currentHash = bundleNameHashDict[loadedBundleName];
                    var newHash     = newBundleNameHashDict[loadedBundleName];

                    // if hash is not matched between current and new, this "on memory assetBundle" is updated.
                    // notify to user.
                    if (currentHash != newHash)
                    {
                        var updatedAssetNames = assetBundleDict[loadedBundleName].GetAllAssetNames();
                        updatedOnMemoryAssetNameAndBundleName(updatedAssetNames, loadedBundleName);
                    }
                }
            }

            // update list.
            this.list = newList;
        }
Ejemplo n.º 5
0
        public AssetBundleLoader(string basePath, AssetBundleList list, Autoya.AssetBundleGetRequestHeaderDelegate requestHeader = null, Autoya.HttpResponseHandlingDelegate httpResponseHandlingDelegate = null)
        {
            this.assetDownloadBasePath = basePath;
            this.list = list;

            if (requestHeader != null)
            {
                this.requestHeader = requestHeader;
            }
            else
            {
                this.requestHeader = BasicRequestHeaderDelegate;
            }

            if (httpResponseHandlingDelegate == null)
            {
                this.httpResponseHandlingDelegate = BasicResponseHandlingDelegate;
            }
            else
            {
                this.httpResponseHandlingDelegate = httpResponseHandlingDelegate;
            }

            /*
             *      construct assetName - AssetBundleName dictionary for fast loading.
             */
            assetNamesAndAssetBundleNamesDict.Clear();

            foreach (var assetBundle in list.assetBundles)
            {
                var bundleName = assetBundle.bundleName;
                foreach (var assetName in assetBundle.assetNames)
                {
                    assetNamesAndAssetBundleNamesDict[assetName] = bundleName;
                }
            }
        }
Ejemplo n.º 6
0
 /**
  *              create preloadList which contains whole assetBundle names in the AssetBundleList.
  */
 public PreloadList(string name, AssetBundleList list)
 {
     this.name        = name;
     this.bundleNames = list.assetBundles.Select(abInfo => abInfo.bundleName).ToArray();
 }
Ejemplo n.º 7
0
 public void UpdateAssetBundleList(AssetBundleList newList)
 {
     assetNamesAndAssetBundleNamesDict = this.bundleListStorage.Update(newList);
 }