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 mirdzana · Mar 04, 2014 at 07:24 AM · instantiatesceneserializationloadingissue

Scene loading time issue

We are working on 2D game. We started working in Unity 3.x, when there was no Sprite support (later switched to Unity 4.x). Currently we are using heavily modified NGUI (only to display sprite and font's) on top of which we created our own GUI framework.

We are encountering a problem with prefab instantiation (instantiation is taking too long to complete). When scene starts, we instantiate ~120 prefabs (some are small some not). Total element count after instantiation is: ~5000 GameObjects, ~20, 000 Components.

After we manually delete all Start, Enable and Awake methods instantiation is still taking ~ 6 seconds (that is time user needs to wait between two game screens), which is not acceptable.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by mirdzana · Mar 04, 2014 at 10:38 AM

We've done a lot of tests to see what's slowing down Unity serialization and tried to optimize our hierarchy.

Some of the strange Unity serialization quirks we've found: - private fields with [SerializeField] are costing drastically more than straight public fields. I guess the difference has something to do with Reflection. - serializing references to [System.Serializable] classes is also extremely expensive - [HideInInspector] fields makes a good amounty of serialization overhead even on Mobile devices (?!) - simple private fields do take a toil on load up time, even through they don't serialize. Then when you add [System.NonSerializable] the cost disappears? - Serializing GameObject field pointing to "None" has a huge overhead which disappers when the field is pointing to GameObject on scene (normally it doesn't cost much more than simple int fields)

We discovered these with a series of experiments. GameObject and MonoBehaviour have their own fix serialization overhead, and then cost gets proportional to the number of fields. You can try to confirm all of these behaviours by making prefabs with dummy MonoBehaviours and add various kinds of fields for Unity to serialize.

Also we discovered Application.LoadLevel() has a fixed overhead of ~200ms which is present even when you open an 1GO scene from an 1GO scene in a new project. We optimized scene so it has something like 2500 GameObjects on scene load, and now the cost of loading the scene is ~1,1s on S4, and more on lower-end devices. We still need more progress. We have an idea of serializing bools with bitmasks, as both our and NGUI code have a lot of those.

The idea of using deactivated gameObjects to delay sceneLoad cost sounds interesting.

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 nesis · Mar 05, 2014 at 02:44 PM 0
Share

Nice detective work there... Good luck! Your best solution it sounds might just need to come down to either incremental loading via a coroutine staggered over many frames (in which case things would pop into view as they load), or just quietly pooling objects to be re-activated as needed (with the obvious constant memory overhead that incurs).

avatar image
0

Answer by nesis · Mar 04, 2014 at 07:42 AM

You might need to look into streaming in prefabs gradually after level load. If you can persist some of them as deactivated GameObjects that get pre-loaded, you'll also avoid the overhead of runtime instantiation.

If there are any nested GameObjects you can collapse into less nested ones, that might help.

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

21 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

Related Questions

Webplayer hangs on loading scene 2 Answers

Instantiate scripts with class relationships 1 Answer

Does scene loading improve performance? 1 Answer

Game flashes to white and desktop while changing scenes 2 Answers

How can i transfer an object from scene1 and instantiate it in scene2? 2 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