Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Fattie · Jun 13, 2012 at 03:05 PM · applicationsplash-screenlevels

Get the NAMES of levels programmatically

When you're on your splash screen, you can in fact get the number of levels available to load.... Application.levelCount

This made me realise that during development you can drop in a handy little "load all your scenes" set of buttons, automatically, in your splash scene, so ...

 function OnGUI ()
     {
     var howManyRealLevels = Application.levelCount - 1;
     for ( var i:int=0; i<howManyRealLevels; ++i )
         {
         if ( GUI.Button( Rect(300, 200 + i*120, 200,100),
                      "scene: " + (i+1) ) )      // LOOK HERE
             Application.LoadLevelAsync( i+1 );
         }
     }


notice "LOOK HERE" in the code. It would be neat if you could just grab the level NAME.

Can it be done? You'd think it's in there in an undocumented list or some such, the thing has to know the names somehow.

(I realize you could look through your own file structure for scenes but that's not a solution, they may not be in there etc. I just want to know if there's a magic to grab the list of names! Just as you can get the count.)

Cheers!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Wolfram · Jun 13, 2012 at 03:09 PM

Duplicate question: http://answers.unity3d.com/questions/33263/how-to-get-names-of-all-available-levels.html

The link also contains a workaround to do this with an editor script before deployment.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image EnsurdFrndship · Oct 20, 2014 at 05:35 PM 0
Share

It works fine until I try to publish my game. Then, I get compiler errors that say...

The name 'UnityEditor.EditorBuildSettingsScene' does not denote a valid type ('not found'). Did you mean 'System.Component$$anonymous$$odel.EditorBrowsableAttribute'?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How come when I restart my level it doesn't work? 2 Answers

iOS application in the settings panel 3 Answers

How can you use Unity to make an iOS app that's not a game? 0 Answers

Storing Application.LoadedLevel As a variable not working. 1 Answer

Can you pass a variable to Application.Load level 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges