Creating a custom 'object builder' editor

Hey,

the title might be a bit vague but here it goes. I would like to build an editor extension where I can select a primitive shape in the inspector, and then when I go to the scene window, the primitive shape will appear there (with low opacity or just the wireframe). You can add more shapes as you like, they can overlap so you can create a more complex shape built out of primitives, a bit like this:

This is just a mockup with some colliders.

Then I’d want a button that ‘builds’ the shape and locks the shapes in place. Then I’d like to get the dimensions of those shapes, their transform, rotation… for other purposes in my project.

What would I use best to achieve a system like this? First thing that comes to mind is using gizmo’s, but I’d like to know if any of you guys thought of other approaches.

Thanks,

Alex

Sounds like Constructive solid geometry (CSG).

How about SabreCSG editor extension?

1 Like

That’s far too complex though, I don’t need to create meshes from those primitives, I just need to know their positions/dimensions. Thanks for the tip though! CSG sounds really interesting, I’ve used Sabre before but I don’t think I used it to it’s full potential. I might take a look at their code and see how they do some of the things I’d like to do.

To draw custom shape in viewport, you need to override OnDrawGizmos/OnDrawGizmosSelected. Basically, draw whatever you want inside those function.

Now, making the shape editable is something I didn’t need to do yet, but it should be documented here:

Ther’es also this question/answer on answerhub:

Alright, so gizmo’s + handles should do the trick! I’m new to handles, looking forward to learning :slight_smile: I’ll just need the basic handles Move/Rotate/Scale and then link that to the position/rotation/scale of the gizmo box, should not be impossible. Thanks!