Was told NOT to use OnGUI for anything except prototyping

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.

So what should I use instead of OnGUI?

If you want a nice GUI system, go buy NGUI on the asset store :smile:

Edit:

Or use a seperate camera (can be othographic for example) with a specfic layer, and then build a gui with 3D objects.

UIToolkit: GitHub - oddgames/UIToolkit: Single draw call UI solution for Unity with multi resolution support and more.

  1. Create a layer called “GUI” or something similar.
  2. Create a camera that’s masked to only draw the “GUI” layer and set to draw on top of your main camera.
  3. 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.

Not really - see this Unite 2007 video. But yes, since the mobile arise, they didn’t made a new version (except they have speed it up like 10x).

However I found out UnityGUI has a good parts, which - when used exclusively - could lead to a good performance.

I use plains with with colliders and textures on them, or TextMesh if text has to be dynamic. I make the text mesh always face the player cam too.