- Home /
Not correct OnGUI documentation
http://docs.unity3d.com/ScriptReference/EventType.Repaint.html
All other events are processed first, then the repaint event is sent.
But my test showed me another!
Upd
Layout 0
Repaint 1
Layout 2
mouseDrag 3
Layout 4
KeyUp 5
Layout 6
mouseDrag 7
Upd
Repaint event are processed first, then the Other events is sent.
My Code:
int V = 0;
void Update () {
Debug.Log("Upd");
V = 0;
}
void OnGUI() {
Debug.Log(Event.current.type.ToString() + " "+ V);
V++;
}
Why?
Answer by Bunny83 · Sep 19, 2015 at 09:23 AM
Your interpretation of your results is just wrong ^^. Update is also called quite late during the frame. Since you check from Update to Update you get the wrong picture. Try adding Time.frameCount to each Debug.Log and you see which call belongs to which frame.
The OnGUI Repaint event is literally the last thing that is executed each frame. I think the only thing that came after is WaitForEndOfFrame coroutines.
You might want to take a look at the flowchart over here. That chart is very simplified and doesn't cover everything, but the over-all structure should be correct.
Just to put that in context of your listing.
"Repaint 1" is actually the last thing that is executed in the current frame
"Layout 2" + "mouseDrag 3" are the first things executed in the next frame
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
How to draw slider thumb on top 0 Answers
Multiple Cars not working 1 Answer