public override TAsset LoadImmediate <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry) { string stringToDeserialize = DeviceManager.LoadImmediate <string>(deviceList, ref entry); JsonService jsonService = Service.Get <JsonService>(); return(jsonService.Deserialize <TAsset>(stringToDeserialize)); }
private AssetRequest <TAsset> loadAsync <TAsset>(string key, AssetLoadedHandler <TAsset> handler = null) where TAsset : class { ContentManifest.AssetEntry entry = getAssetEntry(key); TAsset indexedAsset = getIndexedAsset <TAsset>(entry.Key); AssetRequest <TAsset> assetRequest; CoroutineReturn value; if (indexedAsset != null) { assetRequest = new IndexedAssetRequest <TAsset>(entry.Key, indexedAsset); if (handler != null) { CoroutineRunner.StartPersistent(waitOneFrameBeforeCallingHandler(key, indexedAsset, handler), this, "waitOneFrameBeforeCallingHandler"); } } else if (!activeRequests.TryGetValue(entry.Key, out value)) { activeRequestHandlers.Add(entry.Key, new List <object>()); assetRequest = loadAsyncEntry(ref entry, handler); activeRequests.Add(entry.Key, assetRequest); } else { if (handler != null) { activeRequestHandlers[entry.Key].Add(handler); } assetRequest = (AssetRequest <TAsset>)value; } if (assetRequest == null) { Log.LogError(this, "Failed to load " + key); } return(assetRequest); }
private IEnumerator loadBundleAndDependenciesAsync <TAsset>(string deviceList, ContentManifest.AssetEntry entry, AsyncAssetBundleRequest <TAsset> assetRequest, AssetLoadedHandler <TAsset> handler = null) where TAsset : class { List <AssetRequest <AssetBundle> > bundleRequests = new List <AssetRequest <AssetBundle> >(); List <string> bundlesToLoad = new List <string> { entry.BundleKey }; bundlesToLoad.AddRange(bundleManager.GetDependencyKeys(entry.BundleKey)); for (int i = 0; i < bundlesToLoad.Count; i++) { string bundleKey = bundlesToLoad[i]; if (bundleManager.IsMounted(bundleKey)) { continue; } if (!activeMountRequests.TryGetValue(bundleKey, out var bundleRequest)) { ContentManifest.AssetEntry entry2 = createBundleEntry(bundleKey, deviceList, bundleManager.GetBundleEntry(bundleKey)); activeRequestCount++; bundleRequest = DeviceManager.LoadAsync <AssetBundle>(deviceList, ref entry2, delegate { activeRequestCount--; }); activeMountRequests[bundleKey] = bundleRequest; } bundleRequests.Add(bundleRequest); while (activeRequestCount >= MaxSimultaneousRequests) { yield return(null); } } yield return(waitForBundlesToLoad <TAsset>(pinBundles: deviceList.Contains("sa-bundle"), key: entry.Key, assetPath: entry.AssetPath, bundleRequests: bundleRequests, assetRequest: assetRequest, handler: handler)); }
public override AssetRequest <TAsset> LoadAsync <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry, AssetLoadedHandler <TAsset> handler = null) { if (bundleManager.IsUnmounting(entry.BundleKey)) { bundleManager.CancelUnmount(entry.BundleKey); } AssetRequest <TAsset> assetRequest; if (bundleManager.IsMounted(entry.BundleKey)) { BundleMount bundle = bundleManager.GetBundle(entry.BundleKey); if (entry.Extension.Equals("unity")) { assetRequest = new SceneAssetBundleRequest <TAsset>(entry.Key, entry.BundleKey, null); assetRequest.Finished = true; } else { assetRequest = bundle.LoadAsync(entry.Key, entry.AssetPath, handler); } } else { AsyncAssetBundleRequest <TAsset> asyncAssetBundleRequest = ((!entry.Extension.Equals("unity")) ? new AsyncAssetBundleRequest <TAsset>(entry.Key, null) : new SceneAssetBundleRequest <TAsset>(entry.Key, entry.BundleKey, null)); assetRequest = asyncAssetBundleRequest; CoroutineRunner.StartPersistent(loadBundleAndDependenciesAsync(deviceList, entry, asyncAssetBundleRequest, handler), this, "loadBundleAndDependenciesAsync"); } return(assetRequest); }
public override TAsset LoadImmediate <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry) { if (bundleManager.IsMounted(entry.BundleKey)) { return(bundleManager.GetBundle(entry.BundleKey).LoadImmediate <TAsset>(entry.Key, entry.AssetPath)); } List <string> list = new List <string>(); list.Add(entry.BundleKey); List <string> list2 = list; list2.AddRange(bundleManager.GetDependencyKeys(entry.BundleKey)); BundleMount[] array = new BundleMount[list2.Count]; for (int i = 0; i < list2.Count; i++) { string text = list2[i]; ContentManifest.AssetEntry entry2 = createBundleEntry(text, deviceList, bundleManager.GetBundleEntry(text)); if (!bundleManager.IsMounted(text)) { AssetBundle bundle = DeviceManager.LoadImmediate <AssetBundle>(deviceList, ref entry2); BundleMount bundleMount = (array[i] = bundleManager.MountBundle(text, bundle, deviceList.Contains("sa-bundle"))); } else { array[i] = bundleManager.GetBundle(text); } } BundleMount bundleMount2 = array[0]; return(bundleMount2.LoadImmediate <TAsset>(entry.Key, entry.AssetPath)); }
public override AssetRequest <TAsset> LoadAsync <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry, AssetLoadedHandler <TAsset> handler = null) { AssetRequestWrapper <TAsset> request = new AssetRequestWrapper <TAsset>(null); AsyncAssetRequest <TAsset> asyncAssetRequest = new AsyncAssetRequest <TAsset>(entry.Key, request); CoroutineRunner.StartPersistent(waitForFileStreamAssetToLoad(asyncAssetRequest, entry.AssetPath, handler), this, "waitForFileStreamAssetToLoad"); return(asyncAssetRequest); }
public override AssetRequest <TAsset> LoadAsync <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry, AssetLoadedHandler <TAsset> handler = null) { AssetBundleCreateWrapper assetBundleCreateWrapper = new AssetBundleCreateWrapper(null); AsyncBundleCreateRequest <TAsset> result = new AsyncBundleCreateRequest <TAsset>(entry.Key, assetBundleCreateWrapper); CoroutineRunner.StartPersistent(waitForBundleToCreate(entry.Key, assetBundleCreateWrapper, handler), this, "waitForBundleToCreate"); return(result); }
public override TAsset LoadImmediate <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry) { string bundleKey = entry.BundleKey; AssetBundle assetBundle = AssetBundle.LoadFromFile(bundleKey); Object @object = assetBundle.LoadAsset <Object>("dimpledsphere"); return(@object as TAsset); }
public override AssetRequest <TAsset> LoadAsync <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry, AssetLoadedHandler <TAsset> handler = null) { StreamingAssetBundleWrapper streamingAssetBundleWrapper = new StreamingAssetBundleWrapper(); AsyncStreamingAssetBundleRequest <TAsset> result = new AsyncStreamingAssetBundleRequest <TAsset>(entry.Key, streamingAssetBundleWrapper); CoroutineRunner.StartPersistent(loadBundleFromStreamingAssets(entry, streamingAssetBundleWrapper, handler), this, "loadBundleFromStreamingAssets"); return(result); }
public static TAsset Load(ref ContentManifest.AssetEntry entry) { UnityEngine.Object @object = Resources.Load(entry.Key, typeof(TAsset)); if (@object == null) { throw new ArgumentException("Asset could not be loaded. Is the key correct? Key = " + entry.Key); } return((TAsset)(object)@object); }
public override AssetRequest <TAsset> LoadAsync <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry, AssetLoadedHandler <TAsset> handler = null) { gcsAccessTokenService = Service.Get <IGcsAccessTokenService>(); string bundlePath = UriUtil.Combine(baseUri, entry.Key); AssetBundleWwwWrapper assetBundleWwwWrapper = new AssetBundleWwwWrapper(bundlePath, gcsAccessTokenService); AsyncBundleWwwRequest <TAsset> result = new AsyncBundleWwwRequest <TAsset>(entry.Key, assetBundleWwwWrapper); CoroutineRunner.StartPersistent(waitForBundleToLoad(assetBundleWwwWrapper, handler, entry.IsCacheOnly), this, "Local_waitForBundleToLoad"); return(result); }
private IEnumerator downloadBundle(ContentManifest.BundleEntry bundleEntry) { ContentManifest.AssetEntry entry = new ContentManifest.AssetEntry(bundleEntry.Key, "www-bundle", "unity3d"); numCurrentDownloads++; AssetRequest <AssetBundle> assetRequest = Content.DeviceManager.LoadAsync <AssetBundle>("www-bundle", ref entry); yield return(assetRequest); assetRequest.Asset.Unload(unloadAllLoadedObjects: true); numCurrentDownloads--; }
public override TAsset LoadImmediate <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry) { using (FileStream fileStream = new FileStream(entry.AssetPath, FileMode.Open, FileAccess.Read, FileShare.Read, 1024, useAsync: false)) { using (BinaryReader binaryReader = new BinaryReader(fileStream)) { byte[] array = binaryReader.ReadBytes((int)fileStream.Length); return((TAsset)(object)array); } } }
private IEnumerator loadBundleFromStreamingAssets <TAsset>(ContentManifest.AssetEntry entry, StreamingAssetBundleWrapper wrapper, AssetLoadedHandler <TAsset> handler) where TAsset : class { string key = entry.Key; wrapper.LoadFromDownload(Path.Combine(streamingAssetsPath, entry.Key + ".txt")); yield return(wrapper.WebRequest); AssetBundle assetBundle = wrapper.AssetBundle; handler?.Invoke(key, (TAsset)(object)assetBundle); yield return(null); }
private TAsset loadImmediate <TAsset>(string key) where TAsset : class { ContentManifest.AssetEntry entry = getAssetEntry(key); TAsset val = getIndexedAsset <TAsset>(entry.Key); if (val == null) { val = deviceManager.LoadImmediate <TAsset>(entry.DeviceList, ref entry); assetIndex.Add(entry.Key, val); } return(val); }
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); }
private static bool trySetPinBundle(string assetKey, bool isPinned) { Content content = Service.Get <Content>(); ContentManifest.AssetEntry assetEntry = content.getAssetEntry(assetKey.ToLower()); if (!string.IsNullOrEmpty(assetEntry.BundleKey)) { if (content.bundleManager.TryGetBundle(assetEntry.BundleKey, out var mount)) { mount.IsPinned = isPinned; return(true); } Log.LogErrorFormatted(typeof(Content), "Tried to {2} bundle '{0}' for key '{1}', but bundle was not mounted in BundleManager", assetEntry.BundleKey, assetKey, isPinned ? "pin" : "unpin"); } return(false); }
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); }
private bool unload <TAsset>(string key, bool unloadAllObjects) where TAsset : class { key = key.ToLower(); ContentManifest.AssetEntry assetEntry = getAssetEntry(key); TAsset indexedAsset = getIndexedAsset <TAsset>(key); if (indexedAsset != null) { string bundleKey = assetEntry.BundleKey; if (!string.IsNullOrEmpty(bundleKey) && bundleManager.IsMounted(assetEntry.BundleKey)) { bundleManager.UnmountBundle(bundleKey, unloadAllObjects); } assetIndex.Remove(assetEntry.Key); return(true); } return(false); }
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; } }
public TAsset LoadImmediate <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry) where TAsset : class { prepareDevice(ref deviceList, out var device); return(device.LoadImmediate <TAsset>(deviceList, ref entry)); }
public AssetRequest <TAsset> LoadAsync <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry, AssetLoadedHandler <TAsset> handler = null) where TAsset : class { prepareDevice(ref deviceList, out var device); return(device.LoadAsync(deviceList, ref entry, handler)); }
public override TAsset LoadImmediate <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry) { return(null); }
public override TAsset LoadImmediate <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry) { string text = File.ReadAllText(entry.AssetPath); return((TAsset)(object)text); }
public override TAsset LoadImmediate <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry) { TextAsset textAsset = DeviceManager.LoadImmediate <TextAsset>(deviceList, ref entry); return((TAsset)(object)textAsset.text); }
public static ContentManifest Merge(ContentManifest first, ContentManifest second) { Dictionary <string, ContentManifest.AssetEntry> dictionary = new Dictionary <string, ContentManifest.AssetEntry>(first.AssetEntryMap); foreach (KeyValuePair <string, ContentManifest.AssetEntry> item in second.AssetEntryMap) { dictionary[item.Key] = item.Value; } Dictionary <string, ContentManifest.BundleEntry> dictionary2 = new Dictionary <string, ContentManifest.BundleEntry>(first.BundleEntryMap); foreach (KeyValuePair <string, ContentManifest.BundleEntry> item2 in second.BundleEntryMap) { dictionary2[item2.Key] = item2.Value; } ContentManifest contentManifest = new ContentManifest(); if (second != null) { contentManifest.BaseUri = second.BaseUri; contentManifest.ContentVersion = second.ContentVersion; contentManifest.ContentManifestHash = second.ContentManifestHash; } else if (first != null) { contentManifest.BaseUri = first.BaseUri; contentManifest.ContentVersion = first.ContentVersion; contentManifest.ContentManifestHash = first.ContentManifestHash; } HashSet <string> hashSet = new HashSet <string>(); foreach (KeyValuePair <string, ContentManifest.AssetEntry> item3 in dictionary) { ContentManifest.AssetEntry value = item3.Value; if (!string.IsNullOrEmpty(value.BundleKey)) { hashSet.Add(value.BundleKey); } } foreach (KeyValuePair <string, ContentManifest.BundleEntry> item4 in dictionary2) { ContentManifest.BundleEntry value2 = item4.Value; if (!hashSet.Contains(value2.Key)) { continue; } string[] dependencyBundles = value2.DependencyBundles; foreach (string text in dependencyBundles) { if (!string.IsNullOrEmpty(text)) { hashSet.Add(text); } } } Dictionary <string, ContentManifest.BundleEntry> dictionary3 = new Dictionary <string, ContentManifest.BundleEntry>(); foreach (string item5 in hashSet) { if (string.IsNullOrEmpty(item5)) { throw new Exception("Bundle key cannot be empty when assigning it to Bundle map"); } if (dictionary2.ContainsKey(item5)) { ContentManifest.BundleEntry value3 = dictionary2[item5]; dictionary3.Add(item5, value3); } } contentManifest.AssetEntryMap = dictionary; contentManifest.BundleEntryMap = dictionary3; return(contentManifest); }
public override TAsset LoadImmediate <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry) { throw new InvalidOperationException("Local asset bundles must be loaded asynchronously."); }