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
1
Question by cppietime · Jan 12, 2015 at 04:43 PM · scenescene-loadingbuild settingsfolderapplication.loadlevel

Load Scene from within folder?

If I have a scene(named 'Level1.unity'), saved within a subfolder of assets(named 'NightWorld'), and added it to the Build Settings(listed as 'NightWorld/Level1.unity'), how can I load that using Application.LoadLevel()? I tried Application.LoadLevel("NightWorld/Level1.unity"), but got 'Level couldn't be loaded because it has not been added to the build settings.' Does anyone know why it isn't loading the level even though it clearly shows it in the Build Settings? Do I not just use folder-name/scene-name?

Comment
Add comment · Show 1
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 DoubleIsLoveDoubleIsLife · Jan 13, 2015 at 12:10 AM 0
Share

I think that loading scenes directly is not possible, I could be wrong though. Why not just name them NightWorld1, NightWorld2 etc. $$anonymous$$aybe you could have a 'world' string and a level number variable, combine the two into a string, and load that?

2 Replies

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

Answer by InvincibleCat · Jan 13, 2015 at 12:49 AM

Heu nope... just Application.LoadLevel("Level1");

Comment
Add comment · 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
0

Answer by DFortun81 · Jan 13, 2015 at 12:16 AM

So long as you include the scenes in your build via the Build Settings, you can do the following to load your scene:

 public static void LoadLevel(string name, int sublevel)
 {
     Application.LoadLevel(string.Format("{0}_{1}", name, sublevel));
 }

You could then call it like so:

 LoadLevel("NightWorld", 1);

And it would load the level called "NightWorld_1" if it exists. Not sure if that would throw an exception if it ever fails, but it might be a good idea to surround your call to the function with a try / catch and handle it appropriately with UI messing or something.

EDIT: For more clarification, the way that the level is included in the game is by its name, not its full path. Let's say your level is stored like so: "Levels/NightWord/Level1.unity", when you go to load the level in Unity, all you need to type is "Level1". Unity removes the full path of the level. (This is both a blessing and a curse, I'm afraid.)

Comment
Add comment · 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

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

Scene could not be loaded even though it is in build settings 0 Answers

Application.Loadlevel loads incorrect scene. 0 Answers

"Scene couldn't be loaded because it isn't added to the build settings" but it is? 1 Answer

How to use one object selected from previous scene to the current scene ? 1 Answer

Cannot close/unload a scene that is open in editor during playmode (using C# code)? 3 Answers


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