- Home /
Application.LoadedLevelName for level loaded from asset bundle isn't set
After building an asset bundle for a scene using BuildPipeline.BuildStreamedSceneAssetBundle() I can load the scene from the bundle just fine using Application.LoadLevel(). However, Application.LoadedLevelName is an empty string. This doesn't seem right to me.
I can understand Application.LoadedLevel being -1 (the value it returns for a scene loaded from an asset bundle), but since the scene was loaded using its name, it baffles me that Application.LoadedLevelName should be empty. Am I missing something? Is this a bug? or is it intended behavior?
I've tried searching here and various other sites and haven't managed to find anything dealing with these variables directly when loading scenes from an asset bundle. I know I can write my own wrapper for loading levels and tracking the name, but I'd prefer to utilize the built in functionality of Unity as much as possible.
Thanks!
This does in fact seem to be a bug, at least non-intuitive behavior. I ran into the same problem and was able to work around it by storing the string name of the scene I loaded in a separate variable. I was able to load the level using this variable as the parameter but not with LoadedLevelName. For some reason LoadedLevelName is not being populated with the name from the scene loaded via an Asset Bundle.
Answer by Dreamora · Oct 14, 2011 at 04:33 AM
This is intend behavior I assume because you could have unloaded the asset bundle by now with the unload(false) so loadlevel with the name would no longer work and thats exactly the use case for which LoadedLevelName is there, to reload the current level.
in any other case you would have another reference or something 'telling you where you are' cause you need to know what the next level is or management stuff about the current one
Your answer
![](https://koobas.hobune.stream/wayback/20220613010311im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I store and load levels efficiently? 2 Answers
scene loader issue 0 Answers
Storing in PlayerPref based on timer 1 Answer