- Home /
Lowering the cost of GUI
I recently took the 30 day trial for unity pro to utilise the profiler to see how I could up the efficiency of my game, and I found out that 90% of the time (especially when playing split screen mode) the repaint GUI section was always taking up more than 60% of my MS, I've heard that calling OnGUI has a set overhead cost which ups it by quite a lot, but for me it's actually one of my functions, with 2 cameras it's calling the function 4 times, I have no idea why it's not twice so that's a query, on top of that the shader.setPass call is being called 300 times each call, personally I have no idea what this is doing, but it's taking up a huge amount of the MS, is there any way I can lower this? What does it even do? I only have a few GUI elements, a minimap which is made up of 100 small textures (probably quite inefficient I know, but my maps are randomly generated tiles so the map just makes itself using the same generated numbers, anyone who can think of a more efficient way, your assistance would be much appreciated) and then a line that seperates the two camera views, and that's about it. How can I lower the cost?
many people just say "Don't use unityGUI". $$anonymous$$any other people say "unityGUI is just a scratch tool for development". Ins$$anonymous$$d just simply use the old-fashioned drawtexture, etc. And simply detect touches - after all, it's only a few lines of code with "Rects" galore.
Answer by SirGive · Oct 15, 2011 at 04:13 PM
Unity's GUI is currently very inefficient as it has a high number of draw calls. The way I found to minimize draw calls is an alternative GUI. I'm currently using UIToolkit but there are others out there. One that comes to mind would be EzGUI.
Is there any third party GUI that utilizes batching / atlases and has a multiline textarea?
Your answer
Follow this Question
Related Questions
Applying materials to the new UI elements (4.6) 1 Answer
Image-Effect Shading the GUI? 1 Answer
Custom shader with Unity 4.6 UI Canvas Group Alpha problem 4 Answers
GUIText Outline Shader 1 Answer