Any way to detect when an EditorWindow is being resized?

So I have a function that needs to be called everytime my EditorWindow is manually resized however it is quite a slow function so I don’t want to call it constantly while resizing the window, just once when the resizing has finished. Is there anyway to detect when a Window is being resized other than just checking the size against the last frame? Because that method isn’t very effective as when dragging slowly for example, the size doesn’t actually change every frame so you can’t clearly detect when the resizing starts/stops

Thanks :slight_smile:

edit
So I have this, and it works except for that I have to click the EditorWindow after resizing for it to trigger. My guess being that the resizing of the window “uses” the MouseUp event so it can’t be detected. Any suggestions?

if (window.position.size != lastWindowSize)
     resizeChk = true;
else if(Event.current.isMouse && Event.current.type == EventType.MouseUp)
     resizeChk = false;
          
lastWindowSize = window.position.size;

What you have looks good. What I think you want to do is conceptualize two states… “is moving” and “was moving”. So, first establish your window size has changed during some frame, then the next frame that it doesn’t change size you can guess that the resizing is done, call your function, and reset your counters.

It’s not perfect but if you can’t reliably get the MouseEvent stuff this might be as close as you can get?