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 stenfeio · Apr 28, 2017 at 06:01 AM · unity 5user interface

From an optimization point of view, what optimizes different resources better? Activating/Deactivating UI elements or hiding and showing UI elements using CanvasGroup's alpha?

What is the most optimal way to conserve resources when dealing with a UI-heavy application? Should unshown UI elements be deactivated or should they just be hidden by a CanvasGroup.alpha ?

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
Best Answer

Answer by TonyLi · Apr 28, 2017 at 06:45 PM

Do you want to optimize CPU cycles or memory?

Neither deactivating UI elements nor setting CanvasGroup.alpha to 0 will free up much memory. To do that, you'll want to actually unload the UI elements from the scene.

Also, be aware that (re)activating a UI element will cause it to recalculate layout, as well as meshes for Text components in all children, which can cause a stutter on that frame depending on the complexity of the UI. When optimizing for performance, this is worth considering.

Another alternative to setting a CanvasGroup's alpha to 0 is to disable the CanvasRenderer. Both of these techniques keep the layout in memory so it won't have to recalculate. But they also both keep the UI elements accessible to the GraphicRaycaster for selection by the pointer, and any scripts running on the UI elements will continue to run, unlike deactivating the GameObjects.

The Optimizing UI Controls and Other UI Optimization Techniques And Tips pages contain good information about this subject.

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

Answer by laurentlavigne · Apr 28, 2017 at 05:49 PM

alpha=0 gets culled out of the display list but SetActive(false) or enabled=false gets culled out of the update loop, which is even less work.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Access text label inside a button - Unity 5.1.4 1 Answer

Android performance hit on changing Button.Interactable 1 Answer

Canvas is hiding my 3D model, can I place the model in front of the canvas? 1 Answer

How to make my code stop running, until the player responses to a prompt 1 Answer

UNet and player UI 1 Answer


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