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 YeOldeSnake 1 · Jan 05, 2011 at 06:09 PM · issuesguiskinhiccup

GUI code causes strange GUISkin derived hiccup issues

function OnGUI(){
//GUI.Label (Rect (Screen.width-70, Screen.height-70, 90, 30), musicGameObject.audio.timeSamples.ToString());
GUI.Label (Rect (Screen.width-70, Screen.height-30, 30, 30), hiddenMeterHUD.ToString()+"%");
GUI.Label (Rect ((Screen.width-340)+(noticeMeter)*3, 18, 30, 30), Mathf.Round(noticeMeter).ToString()+"%");
GUI.skin=detectBarSkin;
GUI.Label (Rect (Screen.width-390, 0, 60, 30),"?!!");
GUI.Label (Rect (Screen.width-350, 10, (noticeMeter+10)*3, 10), "  ", "button");
GUI.skin=null;
}

EDIT2:Other GUI code shows this problem as well , such as the one shown above.

EDIT: Here is where the hiccup lies in , i cant find the exact error im doing though http://img833.imageshack.us/img833/6854/tolower.png

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

Answer by cjmarsh · Jan 06, 2011 at 02:53 AM

It seems to me that you have too much going on in this one OnGUI function. Every frame the entire OnGUI function is run through and I imagine that's causing your slowdown issues. You could separate the different menus into different scenes (Main, Options, New Game, etc.) and use Application.LoadLevel() to load each scene with it's own smaller, more condensed OnGUI function. Alternatively, you could create empty game objects with these menus attached, prefab them, and then instantiate and destroy them when you bring up the different menus. Whatever you do, just keeping down the number of operations performed every frame should help speed things up.

Comment
Add comment · Show 2 · 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 YeOldeSnake 1 · Jan 07, 2011 at 07:35 PM 0
Share

Edited the OP with some other code that shouldnt pose a problem but it does pose the exact same slowdown problem

avatar image cjmarsh · Jan 08, 2011 at 02:16 AM 0
Share

Huh, that is very odd. I honestly have no idea what the problem is. $$anonymous$$aybe you should file a bug report and see if you can get a response? Sorry I couldn't be of more help.

avatar image
0

Answer by Harald Scheirich · Apr 24, 2011 at 05:48 PM

You might be getting hit with garbage collection, every call to Rect() creates a new rect, and that every time OnGUI gets called. Try setting up these rects in Awake() or Start() and then just changing that values that need to change

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

No one has followed this question yet.

Related Questions

Basic C# Public Variable Help 3 Answers

Can someone please tell me whats wrong with my code - the error syas it expects to see ')' instead it saw 'hit' (the one after 'out') 1 Answer

How does code licensing for Unity works? What happens when I post for evaluation / showcase? 1 Answer

casting string as type(for passing to method calling for type)? 1 Answer

MouseLock is not working 2 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