コード例 #1
0
 public static float GetDownloadProgress(out float downloadedSize, out float contentSize, out AbUnit unit)
 {
     contentSize    = AbLoaderManager.GetContentSize();
     unit           = AbLoaderManager.ToUnit(ref contentSize);
     downloadedSize = AbLoaderManager.GetDownloadedSize(unit);
     return(AbLoaderManager.GetDownloadProgress());
 }
コード例 #2
0
        public static async Task CheckUpdateAsync(Task <bool> updateRequest = null)
        {
            var   task = AbManifestManager.Instance.CheckUpdateAsync();
            await task;
            var   isUpdate = false;

            if (task.Result == AbUpdateMode.Remind)
            {
                if (updateRequest != null)
                {
                    await updateRequest;
                    isUpdate = updateRequest.Result;
                }
            }
            else if (task.Result == AbUpdateMode.Force)
            {
                isUpdate = true;
            }

            if (isUpdate)
            {
                await AbManifestManager.Instance.UpdateAsync();

                var assetBundles = AbManifestManager.AbManifest.GetAllAssetBundles();
                var tasks        = new Task[assetBundles.Length];
                var abManifest   = AbManifestManager.AbManifest;
                for (int i = 0; i < assetBundles.Length; i++)
                {
                    var loader =
                        AbLoaderManager.Create(assetBundles[i], abManifest.GetAssetBundleHash(assetBundles[i]));
                    tasks[i] = loader.UpdateAbAsync();
                }

                int index = tasks.Length - 1;
                while (index >= 0)
                {
                    if (tasks[index].IsCompleted || tasks[index].IsCanceled || tasks[index].IsFaulted)
                    {
                        index--;
                    }

                    await Task.Yield();
                }

                for (int i = 0; i < assetBundles.Length; i++)
                {
                    AbLoaderManager.Unload(abManifest.GetAssetBundleHash(assetBundles[i]));
                }
            }
            else
            {
                await AbManifestManager.Instance.LoadAsync();
            }
        }