Is there a way to get a level name by index before it is loaded without manually keeping a dictionary?
I’d like to be able to do something like:
string levelName = Application.GetLevelNameByIndex(2);
Is there a way to get a level name by index before it is loaded without manually keeping a dictionary?
I’d like to be able to do something like:
string levelName = Application.GetLevelNameByIndex(2);
The only way to do that is to keep an array of the names of the level. Since you are building it, you probably know the order that the levels are put in, so this would not be that hard of a deal. As per the documentation; There is no way to get the level name before it is loaded.
Maybe put the name in a static variable in your menu script? That way you can always use the variable anywhere. Would need a list though of course.
You could certainly put in a feature request though; Unity obviously has the ability to turn a level name into a level index (and vice-versa) - it’s just not exposed to end users at the moment.