|
I know that with Application.loadedLevelName I can get the name of the current level. But how do I get the names of all available levels? My interest in doing this is to create a level-select menu that lists all levels by name.
(comments are locked)
|
|
I think you'd have to do that manually, since there are no functions that return all level names. That's a shame, it would be useful to enumerate available level names.
Apr 29 '12 at 02:23 AM
numberkruncher
@kruncher: Yes it would be useful ;) I'm pretty sure they implement it the other day, but it's just a minor issue. Until then you could use the script i've just written.
Apr 29 '12 at 03:11 AM
Bunny83
Unity crew, oh please implement a runtime method to get the names of the available scenes.
Oct 30 '12 at 08:58 PM
CarlEmail
where do you attach that script ?
Nov 26 '12 at 10:12 AM
PsionicTr
What about, you put all your scenes in one folder and using .Net framework IO functions read the content in that folder and listed as available levels. Other idea would be the use assets files or XML with the description (text and image), location and configuration on each level, parse the info and display it. But is mandatory you add all the scenes at the building configuration.
Feb 01 at 06:17 PM
y0ux
(comments are locked)
|
|
I've just written a little helper that makes it easier to get the names "manually". You just have to setup your build settings and add all scenes you want to include and then just press the "Update Scene Names" button. This will store the current active scene names in the public array of the script. Where exactly do you attach that script ?
Nov 26 '12 at 10:12 AM
PsionicTr
It doesn't matter where you attach it. Just attach it on an object in the scene. When you want to use the level names you can easily read the scenes array of that script by referencing this script instance in your script. Keep in mind to press the Update Scene Names before you create a build / run the game. You could also make the scenes array static so it can accessed more easily from other scripts.
Nov 26 '12 at 10:52 AM
Bunny83
Well I though so also so I just attached it to one of the game objects but when I press update the array remains empty. Any ideas ?
Nov 26 '12 at 11:45 AM
PsionicTr
I currently have 2 scenes in my assets folder though when I press the UpdateScene Names it does not update the array it still remains 0
Nov 26 '12 at 11:47 AM
PsionicTr
You have to add the scenes to your build array first. Only the scenes which are "ticked" in the build list are even included in your game. Just Press "File --> Build Settings" and drag and drop the scenes which should be part of your game into the "Scenes in build" list.
Nov 26 '12 at 10:41 PM
Bunny83
(comments are locked)
|

Where do you exactly attach that script ?