예제 #1
0
        public override AssetRequest <TAsset> LoadAsync <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry, AssetLoadedHandler <TAsset> handler = null)
        {
            string bundlePath = UriUtil.Combine(baseUri, entry.Key);
            AssetBundleWwwWrapper          assetBundleWwwWrapper = new AssetBundleWwwWrapper(bundlePath, gcsAccessTokenService);
            AsyncBundleWwwRequest <TAsset> result = new AsyncBundleWwwRequest <TAsset>(entry.Key, assetBundleWwwWrapper);
            uint result2 = 0u;

            if (entry.UserData != null && entry.UserData is ContentManifest.BundleEntry && !uint.TryParse(((ContentManifest.BundleEntry)entry.UserData).Crc, out result2))
            {
                result2 = 0u;
            }
            CoroutineRunner.StartPersistent(waitForBundleToLoad(assetBundleWwwWrapper, result2, handler), this, "waitForBundleToLoad");
            return(result);
        }
예제 #2
0
        public PrefabRequest Acquire(PrefabContentKey contentKey, Action <GameObject, PrefabRequest> callback = null)
        {
            PrefabRequest prefabRequest = new PrefabRequest
            {
                IsComplete = false,
                ContentKey = contentKey
            };

            CoroutineRunner.Start(gameObjectContentCache.Acquire(contentKey, delegate(GameObject x)
            {
                onPrefabLoaded(x, prefabRequest, callback);
            }), this, "Loading Prefab Asset");
            return(prefabRequest);
        }
        public static AssetRequest <TAsset> Load(ref ContentManifest.AssetEntry entry, AssetLoadedHandler <TAsset> handler = null)
        {
            ResourceRequest resourceRequest = Resources.LoadAsync(entry.Key, typeof(TAsset));

            if (resourceRequest.isDone && resourceRequest.asset == null)
            {
                throw new ArgumentException("Asset could not be loaded. Is the key correct? Key = " + entry.Key);
            }
            AsyncAssetResourceRequest <TAsset> asyncAssetResourceRequest = new AsyncAssetResourceRequest <TAsset>(entry.Key, resourceRequest);

            if (handler != null)
            {
                CoroutineRunner.StartPersistent(waitForLoadToFinish(entry.Key, asyncAssetResourceRequest, handler), typeof(AsycnResourceLoader <TAsset>), "waitForLoadToFinish");
            }
            return(asyncAssetResourceRequest);
        }
예제 #4
0
        public AsyncAssetBundleRequest <TAsset> LoadAsync <TAsset>(string key, string assetPath, AssetLoadedHandler <TAsset> handler = null) where TAsset : class
        {
            AsyncAssetBundleRequest <TAsset> asyncAssetBundleRequest;

            if (activeRequests.TryGetValue(key, out var value))
            {
                asyncAssetBundleRequest = (AsyncAssetBundleRequest <TAsset>)value;
            }
            else
            {
                asyncAssetBundleRequest = new AsyncAssetBundleRequest <TAsset>(key, null);
                activeRequests[key]     = asyncAssetBundleRequest;
                CoroutineRunner.StartPersistent(waitForAssetToLoad(key, assetPath, asyncAssetBundleRequest, handler), this, "waitForAssetToLoad");
            }
            LastLoadFrame = Time.frameCount;
            return(asyncAssetBundleRequest);
        }
예제 #5
0
        private AssetRequest <TAsset> loadAsyncEntry <TAsset>(ref ContentManifest.AssetEntry entry, AssetLoadedHandler <TAsset> handler = null) where TAsset : class
        {
            bool flag = entry.Extension.Equals("unity");

            if (!flag)
            {
                assetIndex.Reserve(entry.Key);
            }
            try
            {
                AssetRequest <TAsset> assetRequest = deviceManager.LoadAsync(entry.DeviceList, ref entry, handler);
                CoroutineRunner.StartPersistent(waitForLoadToFinish(assetRequest, flag), this, "waitForLoadToFinish");
                return(assetRequest);
            }
            catch (Exception)
            {
                assetIndex.Remove(entry.Key);
                throw;
            }
        }
 private IEnumerator cacheBundles(IList <ContentManifest.BundleEntry> sortedBundles, bool ignorePriority)
 {
     for (int i = 0; i < sortedBundles.Count; i++)
     {
         completeRatio = (float)(i - numCurrentDownloads) / (float)sortedBundles.Count;
         uint maxConcurrentDownloads = (background ? config.MaxConcurrentBackgroundDownloads : config.MaxConcurrentForegroundDownloads);
         while (numCurrentDownloads >= maxConcurrentDownloads)
         {
             maxConcurrentDownloads = (background ? config.MaxConcurrentBackgroundDownloads : config.MaxConcurrentForegroundDownloads);
             yield return(null);
         }
         if (!caching)
         {
             break;
         }
         ContentManifest.BundleEntry bundle = sortedBundles[i];
         if (ignorePriority || bundle.Priority > 0)
         {
             CoroutineRunner.StartPersistent(downloadBundle(bundle), this, "BundlePrecacheManager.downloadBundle()");
             continue;
         }
         break;
     }
     if (sortedBundles.Count > 0)
     {
         while (numCurrentDownloads > 0)
         {
             completeRatio = (float)(sortedBundles.Count - numCurrentDownloads) / (float)sortedBundles.Count;
             yield return(null);
         }
         completeRatio = (float)(sortedBundles.Count - numCurrentDownloads) / (float)sortedBundles.Count;
     }
     if (caching && completeCallback != null)
     {
         completeCallback();
     }
     yield return(null);
 }
 public BundlePrecacheManager(ContentManifest contentManifest)
 {
     SetManifest(contentManifest);
     CoroutineRunner.StartPersistent(loadConfig(), this, "BundlePrecacheManager.loadConfig()");
 }