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
3
Question by Danpob · Sep 20, 2015 at 07:53 AM · uidesign

UI Design - should you hide it, disable it, or destroy it when it is not in use

Hello, I've been reading a few of the best practices posts regarding UI design but still haven't found an answer to the question above. Say I have a game where I tap a button, opens up a menu. Tap another button, closes the menu. When the menu is not open, should it be there in the scene?

Should the menu be instantiated when you call it? or should it be hidden in the scene (invisible or disabled? or off-screen?) and only appear when you need it. (would it make a difference if the platform was mobile?)

My current project has it as disabled and hiding (invisible). My friend on the other hand told me that you're still taking up memory, so best destroy it and instantiate it whenever you need it. I figured instantiating something as often as an in-game menu might take time, so you'll see some noticeable lag, but in his game, it went smoothly.

So just wondering what are some best practices when designing UI in terms of optimization.

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

Answer by Xarbrough · Sep 20, 2015 at 07:58 AM

Generally, you best hide and disable it. Instantiating and destroying are the most expensive operations, so you really shouldn't use them if you don't have to and saving a few kb of memory will most likely not be an issue, but performance spikes on mobile might be. If you make something invisible, it should also be set inactive. Just good practice to prevent errors like being able to select off-screen elements with a controller or some other script accessing that shouldn't be available at that time. Also, you shouldn't care much about optimizing for speed. Optimize for maintainability. ;) Best practices are usually the ones, which make things easy to use and understand.

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
1

Answer by burtonposey · Sep 20, 2015 at 10:28 AM

I agree with everything @Xarbrough said. Another gotcha that I'd add is that you don't want to make a habit of setting objects to alpha of 0 either to denote "not in use". If the alpha tweens to 0, set them to inactive after they reach their target alpha.

I've also worked on games where people moved UI elements off of the edge of the screen. This is a slippery slope, especially when dealing with multiple resolutions as "just off of the screen" could become on screen when the camera's frustum has to change to a different resolution than the default one the scene was setup in.

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 Xarbrough · Sep 20, 2015 at 12:15 PM 0
Share

$$anonymous$$oving elements off screen works pretty well with the new UI system, as far as I've experienced. You can slide off panels by using their pivot in screenspace, which is always normalized, even if the screen/canvas size changed at runtime. But yea, turning off things is always a good idea.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

how to present a 3D Game Object as a UI? 2 Answers

UI Design - seveal screens sharing controls 0 Answers

Screen Edge GameObject Position Pointer 0 Answers

Create big city for car game? 2 Answers

Two panels to fit the size of the parent panel in Portret mode. 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