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 TheNoobieWaffle · Jul 28, 2019 at 03:29 PM · user interfacelayout

UI Scrollbar movement causes layout rebuild

Hi guys, having an issue with lots of nested layout groups. Whenever I scroll a scrollbar the profiler shows the recursive call of calculating all layout elements sizes. I'm not sure how to stop the recalculation. It should not happen in this scenario because the scroll rect is not changing how any child elements should render. Is there any way for me to not have layout groups auto-recalculate and let me, instead, forcefully call a method on them when I want them to recalculate? It would not be difficult to add on that manual code to the established code base I already have. It would be much preferred, but I am not sure how to make it happen!

Any tips would be appreciated, thanks! I know I layout groups are supposed to be used seldomly, but it's a necessary evil for what I am coding. Thus, manually updating them would solve all my issues; just not sure how to do that

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 Divinitize1 · Jul 28, 2019 at 03:59 PM 0
Share

Hi, Not sure if this is exactly what you mean, but you might be able to find useful information in this post, scroll or search for scroll views.

https://learn.unity.com/tutorial/optimizing-unity-ui#5c7f8528edbc2a002053b5a3

"Despite these issues, all approaches can be improved by adding a Rect$$anonymous$$ask2D component to the Scroll View. This component ensures that Scroll View elements that are outside of the Scroll View’s viewport are not included in the list of drawable elements that must have their geometry generated, sorted and analyzed when rebuilding a Canvas."

It's a good read even if it isn't exactly what you're after. All the best.

avatar image TheNoobieWaffle Divinitize1 · Jul 28, 2019 at 04:21 PM 0
Share

Thanks you! This does help. I have not yet solved the issue, but it may be possible with this resource. I see that the page walks you through the rebuild process and what layout elements do. It also has links to source code which should definitely answer my questions after enough snooping

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Ossi101 · Jul 28, 2019 at 05:58 PM

If you are not updating your UI layouts during gameplay you can disable all your layout elements prior to testing/building your game. The resulting positions of these layout elements persist even though they are no longer active. This will help reduce recalculations of these elements at runtime. The only issue here is if you add to a dynamic list of UI objects. In that case you would need to enable all appropriate layout elements then disable them again the next frame to have the new objects be consistent with your initial layout values.

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 TheNoobieWaffle · Jul 28, 2019 at 06:05 PM 0
Share

I've tried this and it improves performance by about 3x, but its not entirely sufficient because 30fps over 10fps isnt near the amount of total performance I should be getting on my relatively powerful PC. I believe, somehow, Rebuild is still being called in the Profiler timeline. I cannot give a definitive answer there because my editor has just decided to render less than 1 frame per second while the profiler is running...

avatar image Ossi101 TheNoobieWaffle · Jul 28, 2019 at 06:13 PM 0
Share

If you haven't done so already try regrouping the UI elements that are static (ones that don't animate, fade or move) into their own canvases. Also the ones that you do modify in such a way into their own as well. That way recalculations only happen on the UI objects that need it. This is a bit tedious but it's the only way I've found to optimize UI performance issues outside of layout groups.


Another thing to keep in $$anonymous$$d are transparencies. If something like a large panel used for fading in and out, if not disabled properly, can compound issues with your other UI objects. $$anonymous$$ake sure you disable canvases that are fully transparent after they are no longer needed and only enable them again if you are going to do work with them. Overlapping transparent UI objects will still trigger their rebuilds even if you cannot see them.

avatar image TheNoobieWaffle Ossi101 · Jul 28, 2019 at 06:45 PM 0
Share

Thank you for the information. I am currently writing up my own code to layout elements effectively. Unused objects are disabled, and re-enabled when necessary. 'Layout' calculations only happen when I need them to. It's pixel pushing but it works for my scenario and using polymorphism, the work of each object that needs to render is less on me because of code re-use. Thank you for you time :)

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

111 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

Related Questions

UI layout groups rearrange children 0 Answers

Rescalable button with text and image 0 Answers

Importing XAML Files 0 Answers

Heavy use of layout groups and content fitters performance 1 Answer

[UI] Profiler scroll rect 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