Creating 3D box collider-like gizmo?
For a tool I'm working on it'd be great if I could make a gizmo that functions like the 3D box collider component has. I've been searching for a while now how to get this to work, but I can't seem to find how this all works. I can draw a gizmo cube with bounds, but I can't wrap my head around how to add in draggable handles (constrained to a single direction). The documentation on Handles doesn't help much either, I have no clue how they work. Anyone have an idea how they work, or know some good tutorials that explains this stuff?
Answer by Adam-Mechtley · May 13, 2017 at 06:26 PM
Hi! You are looking for BoxBoundsHandle. Note that because it is done via Handles (and not Gizmos) you will probably implement it in the OnSceneGUI() callback for a custom Editor. You'll probably find the code example on the page for PrimitiveBoundsHandle.DrawHandle() useful.
That looks exactly like what I'd want! Thank you very much!
Oddly enough, when I try to add the proper namespace (UnityEditor.I$$anonymous$$GUI.Controls) it simply cannot be found. Any clue what can be causing this?
What version of Unity are you using? This class only exists as a public API in Unity 5.6.0 and newer.
Your answer
Follow this Question
Related Questions
Handles.ScaleHandle gizmo gui does not move? 0 Answers
Editor Scripting: Bounds editor with BoxCollider-like scene controls 2 Answers
Gizmo custom Icon tinted by default? 0 Answers
Can I put the 'OnDrawGizmos' code in the CustomEditor? 1 Answer
How do I execute code while dragging an ArcHandle? 0 Answers