-1

I'm working on a project where the user can load assetbundles during runtime, so we only have limited control over what assetbundles are used. Because of that, we have to be careful when we load multiple assetbundles since AssetBundle.LoadFromFile(bundlePath) returns null if a bundle with the same name is already loaded. It will write this Error to the Log:

The AssetBundle 'testbundle' can't be loaded because another AssetBundle with the same files is already loaded.

The main problem now is that I couldn't find a way to get the name of the assetbundle in the file without loading the assetbundle. Using the filename is a workaround, but won't work if people rename the assetbundle file.

pixlhero
  • 418
  • 2
  • 8
  • according to the [API example](https://docs.unity3d.com/ScriptReference/AssetBundle.LoadFromFile.html) it seems that checking for `null` is **THE** way for checking if the bundle can be loaded ... – derHugo Jun 28 '22 at 07:37
  • that is correct. However if I know that the bundle is already loaded I want to know which bundle in my cache I should use. And for that I need the name. – pixlhero Jun 28 '22 at 07:45

1 Answers1

-1

We ended up with a very ugly workaround:

Before we load an assetbundle we have to call UnloadAllAssetBundles. This works because there will never be a name clash. But also makes caching impossible, and we load the same bundle multiple times.

pixlhero
  • 418
  • 2
  • 8