• 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 AntoineCl · Jul 08, 2016 at 12:22 PM · sceneinstantiationruntime-generation

How to pre-build scene at run time?

My scenes are described as custom JSON files. Here is what I am trying to achieve at run time:

  • Player is about to exit current scene and enter next

  • Asynchronously create the next scene and populates it with assets (pre-fabs) described in JSON file

  • When next scene is ready to be displayed, switch to that scene

I already know how to use JSON and create a new scene and objects at runtime.

Issue / questions:

  • Instantiated objects are always created in the currently active scene. How do I add them to a newly created scene before it becomes active?

  • I have the feeling that I am not using right approach (I am new to Unity). What is the best way to pre-load / pre-build dynamically created scenes at runtime?

Thanks,

Comment
Add comment · Show 3
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 tanoshimi · Jul 08, 2016 at 01:31 PM 0
Share

I don't have a definitive answer, but I'm commenting to follow the question since I expect to come up against the same problem shortly. $$anonymous$$y levels are procedurally-generated and I currently generate each new scene upon load, but as the game is growing increasingly complex, this is now taking some considerable time... I've investigated ways of trying to pre-load the scenes up-front and then save them ready to switch to, but AFAI$$anonymous$$ it's not possible to save a dynamically-created scene at runtime.

What I've attempted to do is to use LoadSceneAsync to load the scene additively, and then switch to it when the async operation is complete - I can't tell from your description whether that would work for you too, but that process seems to be a bit buggy/badly-documented, since it appears you can't choose to manually activate a loaded scene if it was loaded additively

(see

  • http://answers.unity3d.com/questions/1073557/additively-loaded-scene-gets-stuck-at-90-even-if-a.html#answer-1073667

  • http://answers.unity3d.com/questions/1146134/unclear-api-of-scenemanagerloadsceneasync-unity-53.html

avatar image gorsefan · Jul 08, 2016 at 02:18 PM 0
Share

This does not answer your question, but can you modify the design to stream the assets in & out of one scene, rather than using multiple scenes? There's a good introductory GDC video by one of the Firewatch developers on this topic, explaining how they made an open world in Unity using this technique.

avatar image AntoineCl · Jul 13, 2016 at 02:42 PM 0
Share

Thanks for your comments. I am currently using the approach suggested by $$anonymous$$sefan. This is not very elegant but it does the job. We will see if someone will come up with a better idea!

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Understanding Prefabs + Player Spawn Points 2 Answers

Lightmapping with Blender Objects in Scene 0 Answers

How to make buttons have sound when it is highlighted and clicked? 0 Answers

Move objects in scene view before running the game 0 Answers

How Move Player between Scenes? 7 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