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 /
  • Help Room /
avatar image
0
Question by yoannG · Jan 06, 2017 at 06:44 AM · performance optimizationtechnicalchoose

Ways to evaluate a programming technique to solve a problem? Ex: GameObject visibility

Hello there,

I am a beginner in programming with C# and Unity, so sorry in advance if it is weird silly talk :).

I am working on my first project, and i am trying to figure out how to evaluate which technique will be best for a given serie of problems. Here is an example:

  • I have "Boxes" which are all consisting of a group of UI Buttons, text, icons. My goal is to give the user the possibility to Hide/Show these different elements as he/she wants.


From these guidelines, i can think of 3 different ways to deal with this:

  • Hide/Show these elements by Activating/Deactivating the gameobject

  • Destroy the gameobject/ Instantiate it when i need it again

  • Set the object to transparent or opaque


The twist is that these boxes will be in a 3D space in which you can navigate, meaning they will be sometimes on screen and sometimes not. That has i guess its importance in order to determine which technique is best?


The question i have are:

  1. Can I evaluate in advance which solution is going to be the most performance effective ? Is there some kind of conscensus which says that for example activate/Deactivate a game object is always slower than destroying instantiating it ?

  2. Are there some lists about these conscensus somewhere ?

  3. Are there other techniques in order to perform this task ?


I am guessing it is all about experience on working on different projects/tasks, though i find it difficult as a beginner to know where to find the informations. If it was not for the Unity community/ Stack Overflow and so on, i would be in real trouble, so thanks again all for being here and be so helpful =)

Note: i stumbled on the profiler thing in unity and will look into what it can do.

Comment
Add comment · Show 1
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 KoenigX3 · Jan 06, 2017 at 05:08 PM 0
Share

I have a question about the situation.

Are these 'Boxes' empty gameobjects, which means that their only purpose is to contain UI elements and to provide an option to hide all those elements at once?

If so, then i would choose the first solution.

Activating and deactivating a main gameobject is relatively easy, fast, and clean. The best part of it is that it will deactivate all of the child elements - which means that the UI elements will also be hidden. The only drawback is that these objects are not easy to be found, when they are deactivated. You should get some references of them before deactivating.

However, instantiating is different - it needs more calculation, which has an impact on the performance. There is nothing wrong with instantiating a few objects at runtime, like firing bullets and stuff, but you can not use it at excessive amounts.

For example, you can optimize a game by using an object pool, rather than instantiating more objects. Object pools store created objects, and inactivate them, when they are not needed. When you need another object (like another bullet), you can reactivate it using the object pool. Of course, it means that the objects the object pool is using are instantiated at the start of the game. (Note: you do not need that in this case, this is just a way of optimization)

Now, the third method is unclear for me. Do you mean, that those 'Boxes' are Cube gameobjects, and it has a $$anonymous$$aterial on it, which can be transparent or opaque? If so, i think this method is not the best option in this case, because it will not affect the UI elements, only the cube (as i know).

As you can see, these methods are for different kind of problems. If you want more information, i would like to know exactly, what your purpose is. Are you trying to create a menu with these, or is it only a test?

0 Replies

· Add your reply
  • Sort: 

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

88 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

Related Questions

All unity games are black screen? 7 Answers

Low framerate on Android devices 0 Answers

What is the best practice for update functions in different scripts attached to same game object? 1 Answer

PostLateUpdate.FinishFrameRendering 2 Answers

any physical/practical limit to number of lights in view? 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