
Hi everyone !
I’ve been looking for an oriented bounding box to use from within a custom editor I’m developing in Unity but I couldn’t find any, except for flaming debates about the laziness of Unity team to bring us one … anyway, today I’m sharing this with you:
https://github.com/aybe/MathGeoLib.Exports
This is a C# wrapper around the outstanding MathGeoLib library, I haven’t implemented everything because it’s really huge, however, I brought the necessary stuff for a decent OBB from within Unity (see the picture above).
It’s pretty fast at OBB’ing and easy to use,
The thing I absolutely wanted to add was the ability to serialize it since it’s naturally not a cheap operation on huge meshes. Personally I didn’t need more than getting its position, extent and axes to be able to draw bounds in my editor, however, I felt it needed a few more methods for querying against it (e.g. point inside, distance, etc) so I’ve implemented quite a few of them but not all since there’s really a lot of them which would imply porting even more types, i.e. snowball effect
.
So there you are, OBB from within Unity, grab the zip release at the first link I’ve posted and see the instructions. Basically you drag and drop native plugins and drop the C# files into your project, things should go smoothly then.
Many thanks to the original author of the library :).
Hope you’ll like it, share your comments/feelings/reviews/whatever !
PS I didn’t add XML comments but the methods and parameters names are evocative enough for a natural usage, in doubt, see the original author documentation in the header (4th link I’ve posted); my wrapper does nothing funny in between, it just passes data back and forth between managed and native worlds.
PS The only change I made to the native library was to enable static linking, DLL is a bit bigger but you won’t need any extra Visual C++ redistributable to drag along with your project (a good thing).
Cheers ![]()

