Drawing a Mesh from an EditorTool
I'm working on an EditorTool to allow me to quickly place objects. A preview mesh of the object to be drawn is generated from the object when the object is selected. I'm drawing that into the scene using Graphics.DrawMesh() in my OnToolGUI(). This generates a LOT of garbage, hoovers up 5-10MB of RAM per second. I've tried moving the function to subscribe to specific events to get it to trigger less frequently, tried using DrawMeshNow() and ...Instanced() which gave identical results, and I'm already filtering to ensure it's only being drawn once per frame. It would be nice to use Gizmos.DrawMesh() but there doesn't seem to be any way for an EditorTool to draw Gizmos. Any suggestions on how to reliably and performantly draw a mesh inside the editor in Unity, without creating a GameObject first?
For reference, here's my current DrawMesh() call:
Graphics.DrawMesh( previewMesh, position, rotation, placeableMaterial, LayerMask.NameToLayer( "Default" ), SceneView.currentDrawingSceneView.camera, 0 );
Your answer
Follow this Question
Related Questions
,My Unity Editor is blurry 0 Answers
Do we have events for +/- buttons for serialized list? 1 Answer
Unity Switching To Scale Tool After Play Testing (which I don't want) 0 Answers
Components can finally be rearranged with the mouse, but since when? 1 Answer
Editor Int sliders affecting each other 0 Answers