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 rt_jscott · Jan 31, 2018 at 10:03 PM · sceneperformancescene-loadingactivate

How can I prevent frame spikes when activating parts of a level?

My project has large linear scenes the player travels through. For performance, we group the scenes in to chunks and keep them "inactive" and set them active when the player gets close to them. My problem is that calling the call to SetActive can cause a large (> 33ms) frame spike. Is there a better way to go about this?

It would be fine if the time spent was at before the level starts, but it seems to have no effect to leave every section active for a few seconds before hiding it.

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
0

Answer by KriskyD · Jan 31, 2018 at 10:19 PM

It may be caused by loading new objects or shaders for the first time. An easy solution is to leave all your chunks active in the scene and set them inactive after game starts. Another way around is to read about Unity methods like Shader.WarmupAllShaders() and similar and to try them out.

Comment
Add comment · Show 3 · 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 rt_jscott · Jan 31, 2018 at 10:38 PM 0
Share

Yes, I think this is part of the problem but there are other issues as well. I still see the spikes even when I do leave them active for a few seconds. I also am using Shader.WarmupAllShaders at level start as well. Even still GameObject.Activate still takes a long time...

avatar image KriskyD rt_jscott · Feb 01, 2018 at 02:03 PM 0
Share

@rt_jscott Try using Coroutines. You can save every gameObject in chunk to list or array and then activate few of them in every frame with one function.

avatar image rt_jscott KriskyD · Feb 01, 2018 at 03:04 PM 0
Share

Oh that's a very good idea! I'll try that out. Thanks!

avatar image
0

Answer by Friedemann_A · Feb 01, 2018 at 02:48 PM

I don't know if this works for you as it would probably require lots of rework in your scene-structure but I think many people split their bigger levels up into multiple scene and use LoadSceneAsync for stuff like this: https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadSceneAsync.html

If you've played "Inside" I think that's what they used there for example.
Hope this helps!

Comment
Add comment · Show 2 · 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 rt_jscott · Feb 01, 2018 at 03:07 PM 0
Share

In fact we've already split our level up in to multiple scenes just so that we can have multiple people work on them. We've got enough memory to load them all, so I hadn't considered bothering to LoadSceneAsync them. Thanks!

avatar image Friedemann_A rt_jscott · Feb 01, 2018 at 04:33 PM 0
Share

Nice, glad I could help :)

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

105 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 avatar image avatar image avatar image avatar image

Related Questions

Classic Resident Evil-style room loading/level streaming? 4 Answers

SceneManager.GetAllScenes() only returns the current scene 3 Answers

Levels: scenes or GameObjects? 3 Answers

Re-loading a scene but on the background older scenes are displayed 1 Answer

Cannot load scene: Invalid scene name (empty string) and invalid build index -1 in Unity Test Runner? 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