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 Gillissie · Mar 16, 2011 at 12:26 AM · guidelaydisplay

UnityGUI display delay

I'm not sure if I'm doing something with UnityGUI that's not recommended, or if it's common for there to be delays the first time labels are displayed. I have up to 2 seconds of delay sometimes when displaying labels. However, after displayed the first time, it is smooth after that.

I assume this delay is from Unity doing something to create the label for the first time. Is there a way to do all this first-time prep before displaying stuff so it displays immediately the first time?

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 Statement · Mar 16, 2011 at 01:52 AM 0
Share

Could you post some source code? This sounds very strange to me, I've never encountered any such behaviour.

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Mar 16, 2011 at 01:15 AM

OnGUI code is immediate mode, which means it's recreated and drawn every frame. So basically it's impossible for there to be any inherent delay; either it's drawn or not. Something in the way your code works is probably the issue.

Comment
Add comment · Show 8 · 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 Gillissie · Mar 16, 2011 at 10:05 PM 0
Share

Alright, I'll see if I can give you a simplified example after looking at my code.

avatar image Gillissie · Mar 28, 2011 at 12:55 AM 0
Share

There is definitely a delay the first time GUI elements are drawn. I assume this is because they have to be created the first time, but are drawn from a buffer after that. I noticed that it only happens on my $$anonymous$$acbook, not on my beefier Windows desktop PC. I suppose it may only be noticeable on slower PC's.

avatar image Eric5h5 · Mar 28, 2011 at 01:40 AM 0
Share

@Gillissie: There is no delay on my 2007 $$anonymous$$ac $$anonymous$$i, which is nearly identical in specs to the older $$anonymous$$acbooks. As I said, the GUI is recreated every frame, so delays aren't even possible, since it's a synchronous operation. You have something else going on. It's not something that happens even on the original iPhone, which is probably 50X slower than your $$anonymous$$acbook. The only thing I can think of offhand is that you're drawing an extremely large texture in the GUI.Label, in which case there will be a freeze when it's first uploaded to the GPU. That's a general issue though, not related to OnGUI.

avatar image Gillissie · Mar 29, 2011 at 05:24 AM 0
Share

There is a 256x256 image on the main menu, and a 16x16 image, but that's it. Everything else is text of various styles. I have 5 GUI modes that display different text. The first time I go to any of the modes, there is the pause. But when I exit the mode and return to it, there is no pause. There's really nothing fancy going on. Here is my entire GUI script code in its entirety: https://gist.github.com/891849

avatar image jimfleming · Apr 06, 2015 at 09:11 PM 1
Share

I've found that dynamic fonts can take quite a bit of time to load. A coroutine that runs once in the background and calls font.RequestCharactersInTexture fixed the problem for me.

Show more comments
avatar image
-1

Answer by Uriel_96 · Mar 16, 2011 at 12:33 AM

Not 100% efficient but maybe this can work:

var startgame = false;
function Update(){
if(startgame == true){
//There go your code
}
}
function OnGUI(){
//Create your label
if(startgame == false){
startgame = true;
}
}

The why of this question I don't know maybe is error of Unity or maybe is yours but this code will make that your game starts when the GUI's are shown

Comment
Add comment · Show 4 · 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 Statement · Mar 16, 2011 at 01:46 AM 0
Share

No need at all to go about that business. See the event order. OnGUI is called after Update. I'm sorry but it is completely redundant. http://unity3d.com/support/documentation/$$anonymous$$anual/Execution%20Order.html

avatar image Statement · Mar 16, 2011 at 01:49 AM 0
Share

Also: http://www.unifycommunity.com/wiki/index.php?title=Event_Execution_Order

avatar image Statement · Mar 16, 2011 at 01:51 AM 0
Share

By the way I am not quite sure what you're trying to do with this snippet. Delay Update until OnGUI has been called once? What is it that you're trying to solve here?

avatar image Uriel_96 · Mar 16, 2011 at 02:04 AM 0
Share

Is because at the final of the question he ask if there is a way to first appear the GUIs and then the do the other stuff so with this as you say update is first but in this case it can not do anything because startgame is false so I GUI after set the label startgame = true so the update function will ask again and it will pass because is true

avatar image
0

Answer by vogg666 · Oct 05, 2015 at 10:06 AM

I had the same issue and i solved it. When i load a level that has some UI Elements, it does a delay. In my case the problem was the font of the UI Text (which is Arial by default). I changed it to Helvetica and the delay is gone. It seems odd but it solved my problem.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Need Text to Display After 5 Seconds 1 Answer

Display GUI Text after delay ? 1 Answer

Problem Displaying Score on GUI text 0 Answers

Display problem with OnGUI 3 Answers

How will display values like table? 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