I just attended the two-day Tokyo Unite conference. During the memory profiling talk the Unity engineer told us NOT/NEVER to use OnGUI in release builds as it’s memory usage is not ideal. He said “use something else”. But he didn’t give us any alternatives and I didn’t get the chance to ask him.
Create a camera that’s masked to only draw the “GUI” layer and set to draw on top of your main camera.
Create whatever assets you want for your GUI as GameObjects, put them in the “GUI” layer where they can be seen by that camera.
This isn’t an ideal system, but it’s more than enough for plenty of games. NGUI is exactly this system, but with a bunch of tools and optimisations.
I don’t think that OnGUI was ever intended for use in release builds, and I think the documentation even says that it’s intended mostly for debugging/Editor purposes, kind of in the same vein as OnDrawGizmos and so on. It seems to work ok for anything aimed at desktops, it’s mobiles (and possibly consoles) where memory performance is of high importance that it becomes a real bottleneck.
Thanks you guys. That is very helpful. I’ll go with the layer/separate camera/special objects for GUI approach as I don’t want to spend a lot of money on nGUI when the new Unity GUI is just around the corner.
I’m not sure if it’s still available, but there used to be a free version of NGUI available via the developer’s website. I’m not sure if it differed from the paid version by license, features or both, but it could be worth checking out.
But for simple stuff there’s really nothing to stop you throwing your own together really easily.