Пример #1
0
        private IEnumerator DownloadAssetBundle()
        {
            downloading = true;
            HTTPRequest request = new HTTPRequest(new Uri("https://VRC.Core.BestHTTP.azurewebsites.net/Content/AssetBundle.html")).Send();

            status = "Download started";
            while (request.State < HTTPRequestStates.Finished)
            {
                yield return((object)new WaitForSeconds(0.1f));

                status += ".";
            }
            switch (request.State)
            {
            case HTTPRequestStates.Finished:
                if (request.Response.IsSuccess)
                {
                    status = $"AssetBundle downloaded! Loaded from local cache: {request.Response.IsFromCache.ToString()}";
                    AssetBundleCreateRequest async = AssetBundle.LoadFromMemoryAsync(request.Response.Data);
                    yield return((object)async);

                    yield return((object)this.StartCoroutine(ProcessAssetBundle(async.get_assetBundle())));
                }
                else
                {
                    status = $"Request finished Successfully, but the server sent an error. Status Code: {request.Response.StatusCode}-{request.Response.Message} Message: {request.Response.DataAsText}";
                    Debug.LogWarning((object)status);
                }
                break;

            case HTTPRequestStates.Error:
                status = "Request Finished with Error! " + ((request.Exception == null) ? "No Exception" : (request.Exception.Message + "\n" + request.Exception.StackTrace));
                Debug.LogError((object)status);
                break;

            case HTTPRequestStates.Aborted:
                status = "Request Aborted!";
                Debug.LogWarning((object)status);
                break;

            case HTTPRequestStates.ConnectionTimedOut:
                status = "Connection Timed Out!";
                Debug.LogError((object)status);
                break;

            case HTTPRequestStates.TimedOut:
                status = "Processing the request Timed Out!";
                Debug.LogError((object)status);
                break;
            }
            downloading = false;
        }
Пример #2
0
 private void Update()
 {
     foreach (KeyValuePair <string, AssetBundleManager.BundlePack> keyValuePair in AssetBundleManager.m_ManifestBundlePack)
     {
         AssetBundleManager.BundlePack bundlePack = keyValuePair.Value;
         foreach (KeyValuePair <string, AssetBundleCreate> createAssetBundle in bundlePack.CreateAssetBundles)
         {
             AssetBundleCreateRequest createRequest = createAssetBundle.Value.m_CreateRequest;
             if (((AsyncOperation)createRequest).get_isDone())
             {
                 bundlePack.LoadedAssetBundles.Add(createAssetBundle.Key, new LoadedAssetBundle(createRequest.get_assetBundle())
                 {
                     m_ReferencedCount = createAssetBundle.Value.m_ReferencedCount
                 });
                 this.keysToRemove.Add(createAssetBundle.Key);
             }
         }
         foreach (string key in this.keysToRemove)
         {
             bundlePack.CreateAssetBundles.Remove(key);
         }
         int index = 0;
         while (index < bundlePack.InProgressOperations.Count)
         {
             if (!bundlePack.InProgressOperations[index].Update())
             {
                 bundlePack.InProgressOperations.RemoveAt(index);
             }
             else
             {
                 ++index;
             }
         }
         this.keysToRemove.Clear();
     }
 }