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?
3 Answers
3
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.
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.
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
Could you post some source code? This sounds very strange to me, I've never encountered any such behaviour.
– Statement