PreloadData is missing. It should always be there.
Hello, I have a big problem with loading scenes from assetbundles. I have to download an Assetbundle that contains a scene and then load it. It works fine the first time, but when I try going back to the first scene and reloading the second one Unity complains saying I have to unload the Assetbundle first because it is duplicated.
So I added the assetbundle.Unload(true) method after calling the SceneManager.LoadScene method. The problem is that now sometimes when changing to the next scene I get the PreloadData is missing. It should always be there error. It appears to be random, sometimes it works, sometimes it doesn't. There is no more information about what it its causing the error and I suspect it is a bug in Unity or something...
Here is my code:
AssetBundle assetBundle = AssetBundle.LoadFromFile(file.Path);
string[] scenePaths = assetBundle.GetAllScenePaths();
string sceneName = System.IO.Path.GetFileNameWithoutExtension(scenePaths[0]);
SceneManager.LoadScene(sceneName);
assetBundle.Unload(true);
I don't understand what I am doing wrong.
Answer by dagerob · Apr 27, 2020 at 04:51 PM
After trying a bit more I found out that the issue is that if you Unload the assetbundle just after loading the scene, sometimes the assetbundle is unloaded before the scene is loaded and that causes the crash. I solved it by unloading the assetbundle in a script that is run in the scene that is being loaded.
Hope this saves someone some ours of research eventually
Your answer
Follow this Question
Related Questions
Unity 5 Survival Shooter Crash 0 Answers
changing scene not working? 0 Answers
Game Over Scene Restart Button 0 Answers
[Unity Beginner] Game design question on scene loading and scene transitioning 0 Answers