Custom editor: EditorGui.DrawPreviewTexture in SceneView only works in the top right corner

Good morning,

I have a custom 2D tile editor tool I wrote for Unity. It allows me to “paint” terrain for my 2D games. I have a “brush tool” and a “draw a rectangle” tool to pain this terrain. When using the rectangle tool, the user drags the mouse in the scene view. When he releases, a rectangle of terrain is created, spanning from the origin of the drag to the end of it. As the user drags the mouse around, I would like to give him a visual feedback of the rectangle he is currently forming. To do so, I am trying to use

void OnSceneView(SceneView view) { EditorGui.DrawPreviewTexture(myWorldCoordinateRectangle, myTexture); view.Repaint(); }

Everything is fine as long as the rectangle is drawn in the top right corner of my scene view, like this:

But the scene view will not draw anything in the other corners. If the rectangle is totally in another corner, it will not be drawn. If it is partly in the top right corner, only the top right corner part of my texture will be drawn.
I have tried to move my scene view camera around, but wherever I place it or whatever the size of my scene view, it is the same issue: only the top right of my camera is drawn:

I have checked my rectangle size using Debug.DrawLine() and it is following the drag correctly in the other corners. I also tried “EditorGUI.DrawRect” and it is the same issue.

Anyone got any idea?

No I didn’t find how to fix it. I decided to draw 4 debug lines to display my square.