This might be a foolish question but… is there a way to do non-rectangular GUI’s (i.e., circles, ovals, or abstract objects)?
I guess you’ll need to specify that question. Non-rectangular in terms of how the stuff looks like? Or clickable areas or so?
Clickables primarily, such as buttons. I’ve got how to create a GUI rectangular button, but could I create it as a circle, or is that just a question of the skin I’m using?
Well I personally would not recommend using the internal UnityGUI. Instead you may have a look at one of those third party solutions out there. The main difference is that you actually use clickable gameObjects rather than programming your GUI from code. Those gameObjects are using colliders to catch your clicks anyway, so it should be possible to use all kinds of primitive colliders or even mesh colliders as well, at least with some little tweaks.
edit: Of course you may also use this idea to create your own GUI system if you don’t want to spend money on that. You’ll just need to re-create the functionality in that case.
These systems also have the advantage that you will end up with 1 draw call for the whole GUI. And not dozens.
About what I figured. Thanks!
I believe that if you can put all of your GUI code into one script, you can get it down to a single draw call. I’m not entirely certain, but I vaguely recall being able to do that in a past project. Essentially, there’s a draw call for every OnGUI function call (again, take with grain of salt/testing). So if you can work your system into a single component that’s only used once per scene, then you may be able to drop the draw calls down a fair bit.
Again, I can’t be certain on that, as it’s been a while since I ran into that issue.
Nope - draw calls have no relation to how many OnGUI methods exist in your project.
Interesting, I’ll have to dig up that project and see what I was doing then, as I do remember that putting all my gui code into one OnGUI method did wind up decreasing the draw calls a significant amount. But, I don’t remember a) which version of Unity it was and b) what all else I was doing to optimize it (probable “re-use” of gui elements amongst other things).
I also remember someone, somewhere having found a way to increase Unity’s GUI performance on Mobile (with relevant profiler results to back it up), but I can’t seem to find it as the Forum search fails at being able to filter on unique threads…so one winds up with 17 pages of replies to a single thread -.-
Lots of games just roll with the old clear colored rect clickable area behind a circular button representation.
Use two rect shaped clickable areas overlapping to create more coverage.
We use NGUI for setting up our GUI. It’s probably the best GUI system for Unity I’ve worked with. There’s new Unity GUI stuff coming in Unity 4.3 so we’ll see if it’s better than NGUI. (Should be, Unity hired the NGUI developer to do the new UI.) There is a free version of older releases of NGUI for non-commercial use.
For circular buttons, usually we have an image of a circle with a box or mesh collider to detect clicks.
As for draw calls, you should be able to get the entire GUI as one draw call as long as everything is on the same atlas and using the same material and positioned correctly. I usually have a camera dedicated to only the GUI which solves a lot of the z-positioning problems. You might need a couple more draw calls if you start getting fancy with the GUI. How the GUI is scripted shouldn’t increase draw calls as rendering doesn’t start until after all the scripts have been updated. (Unless the script starts messing with textures, atlases, materials, or positioning.)