- Home /
Draging a mesh with "Gizmos-context"
Hello,
is there any way to draw a custom mesh (in our case: custom generated) in the context of OnDrawGizmos? More specifically, I really like the feature that you can click on any gizmo drawn using Gizmos.Draw* and it auto-selects the object in which the gizmo has been drawn.
// Works with clicking on the cube, but does not draw a mesh and there is no Gizmos.DrawMesh()
Gizmos.DrawCube(center, outerBounds);
// Draws a custom mesh, but clicking on the area won't auto-select the object where this call is in.
Graphics.DrawMesh(...);
Answer by Immanuel-Scholz · Nov 06, 2013 at 08:24 AM
Just a note how the problem can be "somewhat circumvented":
Graphics.DrawMesh(mesh, ...);
var c = Gizmos.color;
Gizmos.color = new Color(0,0,0,0); // invisible
Gizmos.DrawCube(center, mesh.bounds.size);
Gizmos.color = c;
This will first draw the mesh and then an invisible bounding box gizmo. Picking is not perfect but for some (=our) cases its "good enough".
PS: I'll still leave the question open in the hope that someone figure out how to use UnityEditor.HandleUtility.AddControl
to redirect editor picking to an existing object. I couldn't. ;)
Your answer
Follow this Question
Related Questions
Enable collider "fading" when obstructed (in Editor) 0 Answers
Draw line on play gets distorted 1 Answer
Special folders in subfolders ? 1 Answer
Gizmo for custom cylindrical camera 0 Answers