Hello, I’m working on a Unity project where I have two asset bundles containing different scenes. When I click the level 1 button, it should load the asset bundle scene for level 1, and so on for level 2. But when I go back to the main menu and reopen level 1, it gives me an error message: The AssetBundle ‘Memory’ can’t be loaded because another AssetBundle with the same files is already loaded. Does anyone know how to resolve it?
IEnumerator LoadSceneFromBundle(string bundleUrl, string sceneName)
{
if (!remoteAssetBundle)
{
using (WWW web = new WWW(bundleUrl))
{
yield return web;
if (!string.IsNullOrEmpty(web.error))
{
Debug.LogError("Failed to download AssetBundle from " + bundleUrl + "! Error: " + web.error);
yield break;
}
remoteAssetBundle = web.assetBundle;
}
if (remoteAssetBundle.isStreamedSceneAssetBundle)
{
string[] scenePaths = remoteAssetBundle.GetAllScenePaths();
foreach (var path in scenePaths)
{
Debug.Log("Scene in bundle: " + path);
}
SceneManager.LoadScene(sceneName);
}
else
{
Debug.LogError("Asset Bundle does not contain scenes!");
}
}
}