Hi,
i’m trying to create a tool that ideally is able to display meshes at editor time the same way it does at runtime. At runtime it uses Graphics.DrawMesh() in Update(), no problems there. But i tried everything i can think of to make it work at edit time too. ExecuteInEditMode doesn’t reliably call Update(), OnRenderObject() seems to take it, but somehow buffers the draws up and the editor gets slower and slower until it becomes unusable in about 10 seconds (bug or intended?) i tried keeping lists of rendered objects through OnRenderObject() to not redraw them, but unity clears the draws from the scene under certain circumstances like a random Update()s, so it flickers when something is moved in the scene (and it still buffers up a few times), so that didn’t work well.
DrawMeshNow() with Material.SetPass() works ok but doesn’t include lighting (so it looks different at runtime) and worse, it somehow renders my custom shader completely wrong if i add a pointlight (only in DrawMeshNow(), i’ve compared it with built in shaders but couldn’t find a magic switch).
Subscribing to EditorApplication.update has the same buffering problem as OnRenderObject(), EditorApplication.delayCall too. OnDrawGizmos() can only use DrawMeshNow(), InternalEditorApplication.Set/RemoveCustomLighting() doesn’t do anything, Gizmos.DrawMesh is completely different and not applicable for what i want etc…
So, i’m out of ideas.
How can i use DrawMesh() at editortime, or is there an equivalent method to draw meshes (something like the detailmesh/grass drawing from the builtin terrain)?
Edit: tried OnSceneGUI() too, and it also didn’t work great/buffered up (even with if(repaintevent))