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 rh_galaxy · Jan 22, 2019 at 05:01 PM · scene-loading

Problem loading a scene and initializing it before it is displayed

Before Update() or before the object is drawn, I want the object to be initialized by my code, and it takes say 5+ sec. In order not to freeze at a frame during this time I have tried different approaches.

  • I cannot initialize my object in Awake or Start, because then animation will freeze at a frame.

  • If I do LoadSceneAsync() and wait till its done, the scene is already active.

  • I tried waiting till the 90% asyncLoad.progress mark while having "asyncLoad.allowSceneActivation = false", and then set a bool to true, and detect this in the main thread. I try then to load my data split in 700 chunks to do one chunk each frame. This happens after the constructor has run and before Awake, but the Editor crashes if I try to load an object and set its parent.

new_object.transform.parent = MapGenerator.theMap.transform; //'theMap' is not null, it's set in the obj constructor.

Seems I must do my initialization before LoadSceneAsync(), and then quickly just set the relevant data in Start()... But then I need to create objects and wait to set it's parent until Start() is run... All sorts of problems...
If this is the only way, I think this is a design flaw in Unity... or is there an easy way?

I'm fine with splitting the work into chunks, just need to know when/where I can run this Initialization as long as it's done before the object is drawn, and also before the previous scene is destroyed and stops drawing... seems so bad to have to do it before the scene objects exists...

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 toomasio · Jan 22, 2019 at 06:54 PM 1
Share

maybe hide the scene with a canvas overlay image until everything is "loaded"? You can instantiate the overlay beforehand and use DontDestroyOnLoad so it carries to the next scene.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by rh_galaxy · Jan 23, 2019 at 01:07 AM

I delayed all object creation to be done in Update() during a sequence of frames. Only created the mesh before also during a sequence of frames - that was allowed... accessing the transform after the constructor at 90% progress causes the editor to crash... don't know why this must happen.

I'm missing some incremental Init() member that is run before Start() once every frame until it returns true and keep running the previous scene during this time. That would solve a lot.

Concealing the scene with a plane until it has loaded is no good... because the physics is started then and some objects start to move while others does not exist...

But maybe it is meant to be done in another way...

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

101 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to have multiple scenes concurrently runnning 3 Answers

Load AssetBundles and External Scenes dynamically 0 Answers

Not loading in Chrome 0 Answers

Help with reloading scene for endless runner 2 Answers

Gui Button Not Working After a Scene Load 0 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