GameObject[] LoadVehicleBundles(List <string> bundles) { return(bundles.Select(bundle => { using (ZipFile zip = new ZipFile(bundle)) { Manifest manifest; ZipEntry entry = zip.GetEntry("manifest"); using (var ms = zip.GetInputStream(entry)) { int streamSize = (int)entry.Size; byte[] buffer = new byte[streamSize]; streamSize = ms.Read(buffer, 0, streamSize); manifest = new Deserializer().Deserialize <Manifest>(Encoding.UTF8.GetString(buffer, 0, streamSize)); } var texStream = zip.GetInputStream(zip.GetEntry($"{manifest.bundleGuid}_vehicle_textures")); var textureBundle = AssetBundle.LoadFromStream(texStream, 0, 1 << 20); string platform = SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows ? "windows" : "linux"; var mapStream = zip.GetInputStream(zip.GetEntry($"{manifest.bundleGuid}_vehicle_main_{platform}")); var vehicleBundle = AssetBundle.LoadFromStream(mapStream, 0, 1 << 20); if (vehicleBundle == null) { throw new Exception($"Failed to load '{bundle}' vehicle asset bundle"); } try { var vehicleAssets = vehicleBundle.GetAllAssetNames(); if (vehicleAssets.Length != 1) { throw new Exception($"Unsupported '{bundle}' vehicle asset bundle, only 1 asset expected"); } if (!AssetBundle.GetAllLoadedAssetBundles().Contains(textureBundle)) { textureBundle.LoadAllAssets(); } return vehicleBundle.LoadAsset <GameObject>(vehicleAssets[0]); } finally { textureBundle.Unload(false); vehicleBundle.Unload(false); } } }).ToArray()); }
public static string LoadedAssets(string[] args, GameController ctrl) { string ret = ""; foreach (AssetBundle bundle in AssetBundle.GetAllLoadedAssetBundles()) { foreach (string name in bundle.GetAllAssetNames()) { ret += $"{name}{Environment.NewLine}"; } } return(ret); }
public static AssetBundle LoadAssetBundle(string name, string path) { foreach (AssetBundle assetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (assetBundle.name == name) { assetBundle.Unload(true); break; } } return(AssetBundle.LoadFromFile(path)); }
// 查重 private bool IsABExist(string fileName, ref AssetBundle ab) { IEnumerable liveABList = AssetBundle.GetAllLoadedAssetBundles(); foreach (AssetBundle liveAB in liveABList) { if (liveAB.name.Equals(fileName)) { ab = liveAB; return(true); } } return(false); }
public static List <string> GetAllAssetNames() { if (arrayNames == null) { arrayNames = new List <string>(); } var assetBundles = AssetBundle.GetAllLoadedAssetBundles(); foreach (var item in assetBundles) { arrayNames.Add(item.name); } return(arrayNames); }
static void LoadWeaverAssetBundle() { foreach (var loadedBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (loadedBundle.name == "weavercore_bundle") { weaverAssetBundle = loadedBundle; return; } } string extension = null; if (SystemInfo.operatingSystem.Contains("Windows")) { extension = ".bundle.win"; } else if (SystemInfo.operatingSystem.Contains("Mac")) { extension = ".bundle.mac"; } else if (SystemInfo.operatingSystem.Contains("Linux")) { extension = ".bundle.unix"; } var weaverAssembly = typeof(WeaverAssets).Assembly; foreach (var resourceName in weaverAssembly.GetManifestResourceNames()) { if (resourceName.EndsWith(extension) && resourceName.ToUpper().Contains("WEAVERCORE_BUNDLE")) { try { var bundle = AssetBundle.LoadFromStream(weaverAssembly.GetManifestResourceStream(resourceName)); weaverAssetBundle = bundle; break; } catch (Exception e) { throw new WeaverAssets.WeaverAssetsException("Failed to load the WeaverAssets Asset Bundle", e); } } } if (weaverAssetBundle == null) { throw new WeaverAssets.WeaverAssetsException("Unable to find the WeaverAssets Asset Bundle"); } LoadRegistries(weaverAssetBundle); }
public static Dictionary <string, IControllable> LoadControllablePlugins() { AssetBundle.UnloadAllAssetBundles(false); Dictionary <string, IControllable> prefabs = new Dictionary <string, IControllable>(); var controllableDirectory = Path.Combine(Application.dataPath, "..", "AssetBundles", "Controllables"); if (Directory.Exists(controllableDirectory)) { DirectoryInfo dir = new DirectoryInfo(controllableDirectory); foreach (FileInfo file in dir.GetFiles()) { try { var path = file.FullName; using (ZipFile zip = new ZipFile(path)) { string manfile = Encoding.UTF8.GetString(GetFile(zip, "manifest")); Manifest manifest = new Deserializer().Deserialize <Manifest>(manfile); if (manifest.bundleFormat != BundleConfig.ControllableBundleFormatVersion) { throw new Exception("BundleFormat version mismatch"); } var texStream = zip.GetInputStream(zip.GetEntry($"{manifest.bundleGuid}_controllable_textures")); var textureBundle = AssetBundle.LoadFromStream(texStream, 0, 1 << 20); Assembly.Load(GetFile(zip, $"{manifest.assetName}.dll")); string platform = SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows ? "windows" : "linux"; var pluginStream = zip.GetInputStream(zip.GetEntry($"{manifest.bundleGuid}_controllable_main_{platform}")); AssetBundle pluginBundle = AssetBundle.LoadFromStream(pluginStream); var pluginAssets = pluginBundle.GetAllAssetNames(); if (!AssetBundle.GetAllLoadedAssetBundles().Contains(textureBundle)) { textureBundle.LoadAllAssets(); } prefabs.Add(manifest.assetName, pluginBundle.LoadAsset <GameObject>(pluginAssets[0]).GetComponent <IControllable>()); } } catch (Exception ex) { Debug.LogException(ex); Debug.LogError($"Failed to load controllable plugin {file.FullName}, skipping it."); } } } return(prefabs); }
public static UnityEngine.Object[] GetAssetWithSubAssets(string _bundleName, string _assetName) { var gameBundles = AssetBundle.GetAllLoadedAssetBundles().ToArray(); foreach (AssetBundle ab in gameBundles) { if (ab.name == _bundleName) { return(ab.LoadAssetWithSubAssets(_assetName)); } } Debug.Log("Could not find " + _assetName + " in bundle " + _bundleName); return(null); }
/// <summary> /// Try to load an asset bundle that is already loaded. If it's not /// loaded yet, return false /// </summary> public static bool TryGetLoadedBundle(string name, out AssetBundle loaded) { AssetBundle[] loadedBundles = AssetBundle.GetAllLoadedAssetBundles().ToArray(); foreach (AssetBundle bund in loadedBundles) { if (bund.name == name) { loaded = bund; return(true); } } loaded = null; return(false); }
private static AssetBundle GetAssetBundle(string bundleName) { var bundles = AssetBundle.GetAllLoadedAssetBundles(); foreach (var bundle in bundles) { if (bundle.name == bundleName) { return(bundle); } } var file = Path.Combine(AssetBundlesPath, bundleName); return(AssetBundle.LoadFromFile(file)); }
public IEnumerator SceneTests_UnloadSceneAsync_UnloadSceneAfterAcquireAndDoNotDestroyOnLoadDoesNotUnloadDependenciesUntilSecondRelease() { // Setup scene int bundleCountBeforeTest = AssetBundle.GetAllLoadedAssetBundles().Count(); var activeScene = m_Addressables.LoadSceneAsync(sceneKeys[1], LoadSceneMode.Additive); yield return(activeScene); Assert.AreEqual(AsyncOperationStatus.Succeeded, activeScene.Status); Addressables.ResourceManager.Acquire(activeScene); Assert.AreEqual(activeScene.ReferenceCount, 2); SceneManager.SetActiveScene(activeScene.Result.Scene); Assert.AreEqual(sceneKeys[1], SceneManager.GetActiveScene().name); // Setup obj Assert.IsNull(GameObject.Find(GetPrefabKey())); var instOp = m_Addressables.InstantiateAsync(GetPrefabKey()); yield return(instOp); Assert.AreEqual(AsyncOperationStatus.Succeeded, instOp.Status); Assert.AreEqual(sceneKeys[1], instOp.Result.scene.name); UnityEngine.Object.DontDestroyOnLoad(instOp.Result); int bundleCountAfterInstantiate = AssetBundle.GetAllLoadedAssetBundles().Count(); Assert.Greater(bundleCountAfterInstantiate, bundleCountBeforeTest); // Test yield return(UnloadSceneFromHandlerRefCountCheck(activeScene, m_Addressables)); Assert.NotNull(GameObject.Find(instOp.Result.name)); Assert.IsFalse(activeScene.Result.Scene.isLoaded); int bundleCountAfterUnload = AssetBundle.GetAllLoadedAssetBundles().Count(); Assert.AreEqual(bundleCountAfterInstantiate, bundleCountAfterUnload); Addressables.Release(activeScene); yield return(activeScene); // Cleanup Assert.IsFalse(activeScene.IsValid()); Addressables.Release(instOp); int bundleCountEndTest = AssetBundle.GetAllLoadedAssetBundles().Count(); Assert.AreEqual(bundleCountBeforeTest, bundleCountEndTest); Assert.IsFalse(instOp.IsValid()); }
/// <summary> /// Load Kerbal prefabs. /// </summary> public void Load() { // Shaders between male and female models are inconsistent, female models are missing normal maps and specular // lighting. So, we copy shaders from male materials to respective female materials. Kerbal[] kerbals = Resources.FindObjectsOfTypeAll <Kerbal>(); MaleIva = kerbals.First(k => k.transform.name == "kerbalMale"); FemaleIva = kerbals.First(k => k.transform.name == "kerbalFemale"); MaleEva = PartLoader.getPartInfoByName("kerbalEVA").partPrefab; FemaleEva = PartLoader.getPartInfoByName("kerbalEVAfemale").partPrefab; // Vintage Kerbals don't have prefab models loaded. We need to load them from assets. AssetBundle missionsBundle = AssetBundle.GetAllLoadedAssetBundles() .FirstOrDefault(b => b.name == "makinghistory_assets"); if (missionsBundle != null) { const string maleIvaVintagePrefab = "assets/expansions/missions/kerbals/iva/kerbalmalevintage.prefab"; const string femaleIvaVintagePrefab = "assets/expansions/missions/kerbals/iva/kerbalfemalevintage.prefab"; MaleIvaVintage = missionsBundle.LoadAsset(maleIvaVintagePrefab) as GameObject; FemaleIvaVintage = missionsBundle.LoadAsset(femaleIvaVintagePrefab) as GameObject; MaleEvaVintage = PartLoader.getPartInfoByName("kerbalEVAVintage").partPrefab; FemaleEvaVintage = PartLoader.getPartInfoByName("kerbalEVAfemaleVintage").partPrefab; } // Future Kerbals don't have prefab models loaded. We need to load them from assets. AssetBundle serenityBundle = AssetBundle.GetAllLoadedAssetBundles() .FirstOrDefault(b => b.name == "serenity_assets"); if (serenityBundle != null) { const string maleIvaFuturePrefab = "assets/expansions/serenity/kerbals/iva/kerbalmalefuture.prefab"; const string femaleIvaFuturePrefab = "assets/expansions/serenity/kerbals/iva/kerbalfemalefuture.prefab"; MaleIvaFuture = serenityBundle.LoadAsset(maleIvaFuturePrefab) as GameObject; FemaleIvaFuture = serenityBundle.LoadAsset(femaleIvaFuturePrefab) as GameObject; MaleEvaFuture = PartLoader.getPartInfoByName("kerbalEVAFuture").partPrefab; FemaleEvaFuture = PartLoader.getPartInfoByName("kerbalEVAfemaleFuture").partPrefab; } if (logKerbalHierarchy) { LogHierarchies(); } }
void LogHierarchies(Kerbal maleIva, Part maleEva, Part maleEvaVintage, Kerbal femaleIva, Part femaleEva, Part femaleEvaVintage) { log.Print("Male IVA Hierarchy"); Util.LogDownHierarchy(maleIva.transform); log.Print("Female IVA Hierarchy"); Util.LogDownHierarchy(femaleIva.transform); log.Print("Male EVA Hierarchy"); Util.LogDownHierarchy(maleEva.transform); log.Print("Female EVA Hierarchy"); Util.LogDownHierarchy(femaleEva.transform); // Vintage Kerbals don't have prefab models loaded. We need to load them from assets. AssetBundle makingHistoryBundle = AssetBundle.GetAllLoadedAssetBundles() .FirstOrDefault(b => b.name == "makinghistory_assets"); if (makingHistoryBundle != null) { var maleIvaVintage = makingHistoryBundle .LoadAsset("assets/expansions/missions/kerbals/iva/kerbalmalevintage.prefab") as GameObject; var femaleIvaVintage = makingHistoryBundle .LoadAsset("assets/expansions/missions/kerbals/iva/kerbalfemalevintage.prefab") as GameObject; if (maleIvaVintage != null) { log.Print("Male IVA Vintage Hierarchy"); Util.LogDownHierarchy(maleIvaVintage.transform); UnityEngine.Object.Destroy(maleIvaVintage); } if (maleEvaVintage != null) { log.Print("Male EVA Vintage Hierarchy"); Util.LogDownHierarchy(maleEvaVintage.transform); } if (femaleIvaVintage != null) { log.Print("Female IVA Vintage Hierarchy"); Util.LogDownHierarchy(femaleIvaVintage.transform); UnityEngine.Object.Destroy(femaleIvaVintage); } if (femaleEvaVintage != null) { log.Print("Female EVA Vintage Hierarchy"); Util.LogDownHierarchy(femaleEvaVintage.transform); } } }
public static int GetAllLoadedAssetBundles_s(IntPtr l) { int result; try { IEnumerable <AssetBundle> allLoadedAssetBundles = AssetBundle.GetAllLoadedAssetBundles(); LuaObject.pushValue(l, true); LuaObject.pushValue(l, allLoadedAssetBundles); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
void PlayVideoFromAssetBundle(string src, string bundleString) { string videoStr = bundleString + "videos"; string captionStr = bundleString + "captions"; AssetBundle videoBundle = null; AssetBundle captionsBundle = null; var filename = src.Replace(" ", "_"); foreach (AssetBundle b in AssetBundle.GetAllLoadedAssetBundles()) { if (b.name == videoStr) { videoBundle = b; } if (b.name == captionStr) { captionsBundle = b; } } var vp = GameObject.FindWithTag("App_VideoPlayer").GetComponent <VideoPlayer>(); if (videoBundle != null) { var videoSource = videoBundle.LoadAsset <VideoClip>(filename); vp.clip = videoSource; } else { Debug.LogWarning("no bundle with name " + videoStr); } if (captionsBundle != null) { TextAsset captions = captionsBundle.LoadAsset <TextAsset>(filename); vp.GetComponent <UIB_VideoPlayer>().SetVideoCaptions(captions); } else { Debug.LogWarning("no bundle with name " + captionStr); } StartCoroutine("PlayVideoCoroutine"); }
void OnEnable() { appManager = AppManager.GetInstance(); var assets = AssetBundle.GetAllLoadedAssetBundles(); // AssetBundleCreateRequest bundle = AssetBundle.LoadFromFileAsync(Application.persistentDataPath+ "/AssetData/"+ appManager.characterId+".unity3d"); var ARGameObjects = AssetBundleManager.GetARGameObjects(); char[] charSeparators = new char[] { '-' }; foreach (var item in ARGameObjects) { ARSpriteContainer = GameObject.FindGameObjectWithTag(item.Key.Split(charSeparators)[0]); Instantiate(item.Value.assetGO, ARSpriteContainer.transform); } // var prefab = AssetBundleManager.getAssetPrefab(appManager.characterId + "-ar"); }
public void SetAudio(string PathToAudio, string bundleString) { AssetBundle tmp = null; foreach (AssetBundle b in AssetBundle.GetAllLoadedAssetBundles()) { if (b.name == bundleString) { tmp = b; } } if (tmp != null && src != null) { src.clip = tmp.LoadAsset <AudioClip>(PathToAudio) as AudioClip; src.time = 0; Tools.Init(); } }
public static void LoadControllablePlugin(Manifest manifest, VfsEntry dir) { if (manifest.assetFormat != BundleConfig.Versions[BundleConfig.BundleTypes.Controllable]) { throw new Exception($"manifest version mismatch, expected {BundleConfig.Versions[BundleConfig.BundleTypes.Controllable]}, got {manifest.assetFormat}"); } Assembly pluginSource = LoadAssembly(dir, $"{manifest.assetName}.dll"); string platform = SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows ? "windows" : "linux"; var pluginStream = dir.Find($"{manifest.assetGuid}_controllable_main_{platform}").SeekableStream(); AssetBundle pluginBundle = AssetBundle.LoadFromStream(pluginStream); var pluginAssets = pluginBundle.GetAllAssetNames(); var texDir = dir.Find($"{manifest.assetGuid}_controllable_textures"); if (texDir != null) { var texStream = dir.Find($"{manifest.assetGuid}_controllable_textures").SeekableStream(); var textureBundle = AssetBundle.LoadFromStream(texStream, 0, 1 << 20); if (!AssetBundle.GetAllLoadedAssetBundles().Contains(textureBundle)) { textureBundle.LoadAllAssets(); } } var prefabName = $"{manifest.assetName}.prefab"; //Find a prefab with main asset name ignoring the characters case var mainPrefabName = pluginAssets.First(name => name.IndexOf(prefabName, StringComparison.InvariantCultureIgnoreCase) >= 0); var controllable = pluginBundle.LoadAsset <GameObject>(mainPrefabName).GetComponent <IControllable>(); Controllables.Add(manifest.assetName, controllable); var additionalAssets = new List <GameObject>(); foreach (var pluginAsset in pluginAssets) { if (pluginAsset == mainPrefabName) { continue; } additionalAssets.Add(pluginBundle.LoadAsset <GameObject>(pluginAsset)); } ControllableAssets.Add(controllable, additionalAssets); }
private void UnLoadAllAB() { foreach (AssetBundleHandle handle in _loadedAbDict.Values) { if (handle.Avaliable) { handle.Unload(true); } } _loadedAbDict.Clear(); foreach (AssetBundle ab in AssetBundle.GetAllLoadedAssetBundles()) { ab.Unload(true); } _selectedHandle = null; RecalculateScrollViewAreaSize(); }
public IEnumerator GetRemoteManifest() { var remoteManifestUrl = AssetSys.WebRoot + AssetSys.PlatformName() + "/" + mRemoteVersion + "/" + AssetSys.PlatformName(); var old = AssetBundle.GetAllLoadedAssetBundles().ToList().Find(i => i.name == ""); //AssetBundleManifest); if (old) { AppLog.d(Tag, $"unload AssetBundleManifest {old.name}:{old}"); old.Unload(true); } var temp = Path.GetTempFileName().upath(); yield return(AssetSys.Download(remoteManifestUrl, temp, fs => { mRemoteManifest = AssetBundle.LoadFromStream(fs).LoadAsset <AssetBundleManifest>("AssetBundleManifest"); })); }
public AssetBundle LoadAB(string name, string path = null) { // var ret = AssetBundle.GetAllLoadedAssetBundles().FirstOrDefault((ab) => { return(string.Compare(ab.name, name, true) == 0); //return ab.name == name; }); if (ret != null) { return(ret); } #if UNITY_EDITOR ret = AssetBundle.LoadFromFile(path ?? $"AssetBundles/{name}"); #else #endif return(ret); }
bool LoadedTest(string name, bool expected) { if (IsEditorTest()) { return(expected); } bool actual = false; foreach (var bundle in AssetBundle.GetAllLoadedAssetBundles()) { if (bundle.name == name) { actual = true; break; } } Assert.AreEqual(expected, actual); return(actual); }
void CheckBundleExists() { if (assetBundleCache) { return; } //假设可能存在已经加载过的情况. 所以遍历一下 IEnumerable <AssetBundle> allbundles = AssetBundle.GetAllLoadedAssetBundles(); foreach (var bu in allbundles) { if (bu.name == bundleName) { assetBundleCache = bu; break; } } }
public void Destroy() { GC.Collect(); foreach (var disposable in m_disposables) { disposable.Dispose(); } Container.Clear(); Resources.UnloadUnusedAssets(); var bundles = AssetBundle.GetAllLoadedAssetBundles(); foreach (var bundle in bundles) { Debug.LogError($"Unreleased asset bundle : {bundle.name}"); } AssetBundle.UnloadAllAssetBundles(true); }
/// <summary>Call this to load all the assetbundle in Bundle folder</summary> public static List <AssetBundle> LoadAllAssetBundle( ) { List <AssetBundle> bundles = new List <AssetBundle> ( ); bundles.AddRange(AssetBundle.GetAllLoadedAssetBundles( )); string path = Application.persistentDataPath + "/Bundle"; CheckDirectory(path); string [] allfile = Directory.GetFiles(path); foreach (string file in allfile) { bool bLoaded = false; //if the file doesn't have extension will be the assetbundle file if (!Path.HasExtension(file)) { //make sure the bundle is already loaded or not foreach (AssetBundle item in bundles) { if (Path.GetFileNameWithoutExtension(file) == item.name) { bLoaded = true; break; } } if (!bLoaded) { AssetBundle SheetBundle = AssetBundle.LoadFromFile(Path.Combine(path, Path.GetFileNameWithoutExtension(file))); if (SheetBundle == null) { return(null); } else { bundles.Add(SheetBundle); } } } } return(bundles); }
public static List <T> LoadResources <T>(string[] names, string assetName) where T : class { FileInfo[] files = new DirectoryInfo(BetterStreamingAssets.Root + "/WaterBending/Bundles").GetFiles(assetName + ".assets", SearchOption.AllDirectories); AssetBundle assetBundle; if (AssetBundle.GetAllLoadedAssetBundles().Count() > 0) { if (AssetBundle.GetAllLoadedAssetBundles().Where(x => files[0].Name.Contains(x.name)).Count() == 0) { assetBundle = AssetBundle.LoadFromFile(files[0].FullName); } else { assetBundle = AssetBundle.GetAllLoadedAssetBundles().Where(x => files[0].Name.Contains(x.name)).First(); } } else { assetBundle = AssetBundle.LoadFromFile(files[0].FullName); } List <T> objects = new List <T>(); foreach (string k in assetBundle.GetAllAssetNames()) { foreach (string j in names) { if (k.Contains(j)) { objects.Add(assetBundle.LoadAsset(k) as T); Debug.Log(Assembly.GetExecutingAssembly().GetName() + " loaded asset: " + k); } } } if (objects.Count == 0) { Debug.LogError(Assembly.GetExecutingAssembly().GetName() + " found no objects in array. The functions may not work as intended."); return(null); } return(objects); }
/// <summary> /// Get all tilesets from loaded assetbundles. /// </summary> /// <returns></returns> static void LoadBundleData() { foreach (AssetBundle bundle in AssetBundle.GetAllLoadedAssetBundles()) { foreach (GameAsset asset in bundle.LoadAllAssets <GameAsset>()) { if (!LoadedGameAssets.ContainsKey(asset.AssetStringID)) { LoadedGameAssets.Add(asset.AssetStringID, asset); } } var assetInfoName = $"{bundle.name}_assetinfo.json"; if (bundle.Contains(assetInfoName)) { var assetInfoJson = bundle.LoadAsset(assetInfoName) as TextAsset; var assetInfo = IOHelper.DeserializeAssetInfo(assetInfoJson); AssetManager.PopulateAssetInfo(assetInfo); } } }
public static void LoadControllablePlugin(Manifest manifest, VfsEntry dir) { if (manifest.bundleFormat != BundleConfig.Versions[BundleConfig.BundleTypes.Controllable]) { throw new Exception($"manifest version mismatch, expected {BundleConfig.Versions[BundleConfig.BundleTypes.Controllable]}, got {manifest.bundleFormat}"); } var texStream = dir.Find($"{manifest.assetGuid}_controllable_textures").SeekableStream(); var textureBundle = AssetBundle.LoadFromStream(texStream, 0, 1 << 20); Assembly pluginSource = loadAssembly(dir, $"{manifest.assetName}.dll"); string platform = SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows ? "windows" : "linux"; var pluginStream = dir.Find($"{manifest.assetGuid}_controllable_main_{platform}").SeekableStream(); AssetBundle pluginBundle = AssetBundle.LoadFromStream(pluginStream); var pluginAssets = pluginBundle.GetAllAssetNames(); if (!AssetBundle.GetAllLoadedAssetBundles().Contains(textureBundle)) { textureBundle.LoadAllAssets(); } Controllables.Add(manifest.assetName, pluginBundle.LoadAsset <GameObject>(pluginAssets[0]).GetComponent <IControllable>()); }
private void Update() { foreach (var allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { Debug.Log("+++" + allLoadedAssetBundle.name); var allScenePaths = allLoadedAssetBundle.GetAllScenePaths(); Debug.Log(allScenePaths); } Debug.Log(ObjectiveCount); if (ObjectiveCount == 0) { RespawnCount = 0; ObjectiveCount = InitialObjectiveCount; Debug.Log("Loading Scene " + nextScene); SceneManager.LoadScene("Assets/Scenes/" + nextScene + ".unity"); } RemainingTime -= Time.deltaTime; if (RemainingTime < 0) { RestartScene(); } }
public static AssetBundle LoadAssetBundle(string abName) { abName = abName.ToLower(); IEnumerable bundles = AssetBundle.GetAllLoadedAssetBundles(); foreach (AssetBundle b in bundles) { if (b.name == abName) { return(b); } } if (Manifest == null) { Manifest = new Dictionary <string, List <string> >(); LoadManifestFile(); } AssetBundle bundle = AssetBundle.LoadFromFile(GetAssetBundleFolderPath() + abName); if (!Manifest.ContainsKey(bundle.name)) { Debug.Log(bundle.name); } List <string> dependencies = Manifest[bundle.name]; foreach (string dependency in dependencies) { LoadAssetBundle(dependency); } return(bundle); }