Editorwindow zoom by mouseposition !!

hi
I spend lots of time to solve this problem ,but I couldn’t make non of these works.
I just want to make my editorwindow zoom by where mouse is.
here the codes I have tried.

    Vector2 curPos;
    float zoomScale=1;
    void zoom()
    {
        if (Event.current.type == EventType.ScrollWheel) {
            if (zoomScale + Event.current.delta.y / 50 > 0) {
                zoomScale += Event.current.delta.y / 50;
            }
            curPos = Event.current.mousePosition * zoomScale;
        }
        EditorGUIUtility.ScaleAroundPivot (Vector2.one * zoomScale, curPos);
        Repaint ();
    }

with this code it is almost works but it will translate my gui too.
so who know what to do !?

        matrix_BeforeScaling = GUI.matrix;
        pivotPoint = new Vector2( rect_ScrollView_Cont.x + scrollPos.x - offsetScaleArea_X, rect_ScrollView_Cont.y + scrollPos.y - offsetScaleArea_Y );
        GUIUtility.ScaleAroundPivot( scalePanel, pivotPoint );
        //GUIUtility.RotateAroundPivot( fRot, pivotPoint );
        matrix_AfterScaling = GUI.matrix;


....


       GUI.matrix = matrix_BeforeScaling;

I forgot allot of how to do it… since i added it to my extension (kissUI), 2 years or so ago…

Sadly enough, i never bothered with making sure it zoomed in using the mouse position yet. :frowning:

no, not working, you didn’t even get mouseposition at all !
if i wrote it like this it would works but it always move gui by mouse moving in contex,

if (Event.current.type == EventType.ScrollWheel) {
            if (zoomScale + Event.current.delta.y / 50 > 0) {
                zoomScale += Event.current.delta.y / 50;
            }
        }
        curPos = Event.current.mousePosition * zoomScale;
        EditorGUIUtility.ScaleAroundPivot (Vector2.one * zoomScale, curPos);
        Repaint ();