Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 ina · Mar 14, 2011 at 08:09 AM · androidguiiphoneonguiguistyle

Optimizing OnGUI - Too many gui elements?

Is there such a thing as too many gui elements? I find that when I deactivate the gui completely, my app runs a LOT faster. Is there a maximum number of recommended gui elements?

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
0

Answer by Lab013 · Mar 14, 2011 at 08:17 AM

The OnGUI is quite slow. It gets called twice a frame and it will slow down your game. How much it will slow you down is dependent on the computer, the type of computational work your game will force mostly, and the GUI elements/styles you use. Usually on a computer its not too big a deal. If you find it is a big deal, then you should use cheaper alternatives such as GUITexture (which can still become expensive if you use it terribly).

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 ina · Mar 15, 2011 at 03:37 AM 0
Share

well, the alternative is to use collision on gameobjects for buttons... would that be better than gui?

avatar image
0

Answer by swartzcr · Aug 24, 2011 at 05:17 PM

One way to get around this is to have a GUI Manger script which has the arguements from each normal onGUI passed to it, so that you manager is the only thing running the actual onGUI function, while still displaying what any of the other onGUI functions normally would.

So you would do something like if(clicked){ GuiManager.state = tree; GuiManager.treeHeight = this.height; } on your trees whose height pops up in the GUI when clicked and onGUI{ if(state == tree){ if(GUI.Button(rect(x,y,x,y), treeHeight+"\n close?") } } on your GUIManager, with a slot for all of your previous different onGUIs in it. That way only one script is running onGUI multiple times a frame, but you still get the experience of everything creating a GUI texture when clicked.

(I apologize if my poorly written example code is confusing, but I hope the concept is still clear)

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

1 Person is following this question.

avatar image

Related Questions

How to Focus GUI.TextArea in Unity for Android 0 Answers

iPhone Touch Screen? 2 Answers

How to use GUIStyles in OnInspectorGUI? 1 Answer

GUI system for android? 1 Answer

Unity Android Remote GUI Scaling issues 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