I am trying to call “Graphics.DrawMeshInstanced” in Edit mode by adding [ExecuteInEditMode] to a Monobehaviour that calls Graphics.DrawMeshInstanced from it’s Update().
It’s not rendering anything.
There are several other Instanced Rendering workflows. Like via CommandBuffers or via OnRenderObject etc.
Is there any way to use Instanced Rendering in Edit Mode?
Hey there,
I did some more testing and exploration and found that Graphics.DrawMeshInstanced does work in Edit mode.
I have got my system working now by calling Graphics.DrawMeshInstanced twice per batch, once to Camera.current (for scene view) and once using a reference to my game’s camera.
I had to add a specific call to the Renderer in OnSceneGui like so
void OnSceneGui() {
if (Event.current.type == EventType.Repaint) {
InstancedRenderer.Instance.Render();
}
…
}
And in order to redraw the game view from OnInspectorGui I had to set a bool to true and then add
void OnSceneGUI() {
if (doRedraw) {
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
doRedraw = false;
}
}