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?
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.