One OnGUI() to control them all + smooth movement of groups

Hello all,

Is it safe to just have one OnGUI function?

function OnGUI()
{
 //1st group of GUI 
 GUI.BeginGroup(Rect(..........
 GUI.whatever over here......
 GUI.EndGroup();

//2nd Group of GUI
 GUI.BeginGroup(Rect(..........
 GUI.whatever over here......
 GUI.EndGroup();

//3rd Group of GUI
 GUI.BeginGroup(Rect(..........
 GUI.whatever over here......
 GUI.EndGroup();

Also, I’m trying to smooth move a group by changing the groups Rect when a button is pressed, can I used .deltaTime to move the GUI groups somewhat slowy.?

Thanks,
Ray

Yes, you can have everything inside one OnGUI function or split into separate ones… Up to you

I’d recommend smoothing the movements in an Update function.

Thanks Sir Nich.

:smile:

Ray

Sir Nicholas - seems you’ve been knighted :wink:

The smoothing thing brings up a question- GUI.DragWindow exhibits some tearing even with we tell Unity to sync with the vertical refresh. If I understand correctly, the first OnGUI pass calculates the layout, and second draws the controls. Are Windows handled any differently, since they are contained in a separate function?