- Home /
Is Mesh Collider Optimal for GUI?
I'm using textureless (without a mesh renderer) simple planes for detecting touches on GUI buttons. They come with a box collider by default, but I'm changing them to mesh collider, as it sounds more performance-friendly. Am I doing a right thing? (ofc I'm checking the "is trigger" box, too)
Unity's own GUI engine is not fit for me btw.
Answer by Eric5h5 · Mar 07, 2013 at 09:26 PM
You should not use mesh colliders unless there's no other choice. All other colliders are much faster. In other words, don't change the box collider to a mesh collider.
Hmm, can you be more precise (show some reference links, etc.)?
I expect a mesh collider to be mesh dependent. I mean, if my mesh is more complex, then the collider is too. Isn't it working that way, what am I missing here?
That's true, but the least-complex mesh collider is still more complex than a box collider. You can't make any assumptions about meshes, therefore optimization options are limited, whereas you can make a number of assumptions about a box collider (primarily: it's always a box!) therefore it can be optimized a lot more.
Also, you're always getting a bounding box with a mesh collider anyway (so tests can be done against that first before doing more complex mesh stuff if necessary), so you might as well do only the bounding box and dispense with the rest.
Ok, so you're saying it's not possible a mesh collider to be more complex than a box one, even if my meshes are the simplest 2 triangle planes (made with this: http://wiki.unity3d.com/index.php?title=CreatePlane) which they all are.
So, I'm accepting this answer, thank you.
I'm saying the opposite of that actually. :) It's not possible for a mesh collider to be simpler than a box collider.
Haha, sorry for my English. I meant exactly that. Let's just say "Box" is BETTER than "$$anonymous$$esh" in this situation.
Answer by justin_iSO · Mar 07, 2013 at 07:01 PM
This is probably okay performance wise (assuming you don't go crazy and have a million buttons). However, if the screen resolution changes, you run a risk of your planes not being aligned with your GUI.
The game I'm making is for iPad, so it will be in fixed resolution. Thanks for the warning anyway.
Sounds good. I have used this method before and it worked fine for me.
Your answer
Follow this Question
Related Questions
Box colliders from procedural mesh 1 Answer
proper inventory system issue.. 1 Answer
[Particles] Restrict particles inside a Mesh 1 Answer
Primitive Collider slower then mesh collider 0 Answers
GUI.Button error 1 Answer