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 CaseyHofland · Mar 05, 2019 at 09:11 AM · editorrenderinglaghierarchyslow

Strange Hierarchy Lag

I have a Unity Scene with a field of 10.000 models of magnet boards, and I got it running smooth in the Scene Editor. Except... when I select it, then I get horrible lag when moving around. I was wondering what's different and why this is happening.

Some more Info:
- Profiler shows CPU Usage is a little bit below 30 fps when moving around in scene view normally, rendering taking up ~90% of energy.
- Profiler shows CPU usage slower than 15 fps when moving around in scene view with object selected, rendering taking up ~95% of energy.
- No colliders, No other components, no editor scripts, just meshes in LOD groups in empty parents.
- No lag when working in the hierarchy, even on the object itself.
- No lag when a single model selected.
- The object is from root to child all static.
- Every magnet board has a low poly version that I switch between with a LOD group (though how this could make things slower I can't imagine).
- The Hierarchy item contains, in total plus itself included, 31.111 objects (the 1's are parents of 10 to keep it clean.) I'm not transforming any of the empty parents.

It seems to me that when a model in the hierarchy is selected, it is "rendered" twice, or at least the profiler has me believe so. Why is that happening and how to fix it?

P.S. I know creating a single model out of 10.000 magnet boards will reduce rendering time and I'll do so once the model is locked, but this still seems like an interesting problem to me and I couldn't figure it out with Google.

Comment
Add comment · Show 2
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 troien · Mar 05, 2019 at 11:22 AM 0
Share

I post this as a comment ins$$anonymous$$d of an aswer, because I'm not sure if this is the main cause of the lag, but I'm pretty sure this is atleast part of it.

$$anonymous$$y guess would be that Unity is trying to render the gizmo outlines of selected objects (this outline is drawn for the object you select AND all child objects. Drawing gizmo's also takes up cpu time, as there is (over simplified) a piece of code that is executed by the cpu that loops all selected objects and then adds their outlines to a buffer for the gpu to render. It is done in a way similarly of how you could implement drawing OnGUI or gizmos yourself. Normally this has little to no impact because the cpu doesn't have a lot to do in edit mode anyway, but having to loop 31111 objects (and actually drawing the outlines) is a lot to do for the cpu.

Outside of playmode, the scene only updates (and with it, redraws gizmos) if there are any changes to any objects or when moving the scene camera. Sinse when you move the scene camera it has to update multiple times a second as opposed to just once when you change something in the inspector. The lag will be more noticeable when moving the scene camera.

You could try clicking 'gizmos' in the top right of your scene view and uncheck 'selection outline'. $$anonymous$$y guess is that this should make at least a no$$anonymous$$ble difference.

avatar image CaseyHofland troien · Mar 05, 2019 at 07:48 PM 0
Share

Troien, you got it in one! Turning off selection outline fixed my problem immediately, I would have never thought of that! Post it as an answer and I'll mark it so others can find it!

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by troien · Mar 05, 2019 at 08:38 PM

As mentioned in the comments.

When you select something in the hierarchy, Unity tries to render the gizmo outlines of selected objects. This outline is drawn for the object you select AND all child objects. Drawing gizmo's also takes up cpu time, as there is (over simplified) a piece of code that is executed by the cpu that loops all selected objects and then adds their outlines to a buffer for the gpu to render. It is done in a way similarly of how you could implement drawing OnGUI or gizmos yourself. Normally this has little to no impact because the cpu doesn't have a lot to do in edit mode anyway, but having to loop 31111 objects (and actually drawing the outlines) is a lot to do for the cpu.


Outside of playmode, the scene only updates (and with it, redraws gizmos) if there are any changes to any objects or when moving the scene camera. Sinse when you move the scene camera it has to update multiple times a second as opposed to just once when you change something in the inspector. The lag will be more noticeable when moving the scene camera.


You could try clicking 'gizmos' in the top right of your scene view and uncheck 'selection outline'. This should make a noteable difference.


For other people who have similar problems, but for who this didn't work. I don't know of any other thing that Unity does in the background with selections that could give a noteable difference (doesn't mean there are none). But if you select a lot of objects that have a MonoBehaviour with OnDrawGizmosSelected implemented (Some builtin Unity ones might have that aswell) you get the same problem, in that case disabling the gizmos of that specific MonoBehaviour might help aswell.

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 Yany · May 17, 2019 at 11:22 AM 0
Share

For me the "Selection outline" was a game changer. For 1-2 thousands of prefab instances the difference was astonishing. With outline I had about 20-30 fps in the editor while it easily reached the monitor's refresh rate (75 Hz) after I turned it off.

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

150 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 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

Unity is reacting really slow, and it opens a second instance of the Editor 2 Answers

Unresponsive Unity Editor 2 Answers

Lag in Inspector 0 Answers

What is the best way to draw icons in Unity's Hierarchy window? 1 Answer

keep gameObject in hierarchy folded when not selected 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