[Solved] Graphics.DrawMeshInstancedIndirect and ExecuteInEditMode

This thing is really really slow in edit mode. Runs fine in play mode, but super slow in edit mode.

Certainly due to mouse events, drag, release, the whole lot, all cause the scene view to refrehs, which will all cause Graphics.DrawMeshInstancedIndirect to run needlessly.

I did get a very good framerate increase by adding

            if (!Application.isPlaying && Event.current != null) {
                return;
            }

But it’s still super slow. What else can I do to ensure that it runs only once, and only during the ‘last’ scene redraw?

If “once” refers to once per frame, perhaps OnRenderObject is what you’re looking for:

Theoretically it should’ve been perfect, but it got even slower somehow

EditorApplication.QueuePlayerLoopUpdate solves the issue perfectly, this was added in 2017.2, so you will need to update if you need this

1 Like