Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 InfinitaSalo · Nov 28, 2016 at 08:03 AM · scene-loadingbuild settingsscene-change

How do I create a scene during runtime, add it to the build settings, and open it using code?

I am trying to create a game in Unity 2D. The game contains a map with many circles that can be clicked on. Clicking on each circle leads to a different scene. However, since there are thousands of circles and thousands of potential scenes, I don't want to create each scene beforehand, as that would be very time-consuming and take up lots of memory. I want to only store scenes that have been opened so far. What I am trying to do is, when a circle is clicked, generate a scene. Then, add this scene to the build settings (using code) and open the scene. Is there a way to do this during runtime only using code?

So far, I am able to create the scene, and add it to the build settings; however, when I open the build settings, the scene is present, but not checked off. The scene also appears in a grayish color instead of the black color the other scene names appear in. When I try to open the scene it gives an error message which says that 'sceneName' (-1) couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.

Here is my code:

alt text

Here are the build settings with the original scene on top and the generated scene below it:

alt text

Any help with this would be greatly appreciated. Thanks!

scenegenerate.png (33.0 kB)
buildscenes.png (42.7 kB)
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
0

Answer by mikaelK · Jun 06, 2020 at 10:18 PM

I know this is bit late, but I had this same problem and changing scene load to use index instead of path worked for me.

EditorSceneManager.LoadScene(yourLoadedSceneIndex, SceneMode.Single);

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

Saving and loading user made configuations 0 Answers

Display a GameOver scene then restart the game 1 Answer

SceneManager.Load is not worked in subfolders 1 Answer

Fadeout Issue 0 Answers

SceneManager.LoadSceneAsync stops coroutine 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