In the Unity Editor, is there a callback for window layout change?

In the Unity Editor, is there a callback for window layout change?
9868266--1422294--upload_2024-6-2_11-38-39.png

I have added some tool buttons in the Editor Toolbar area, but when the window layout changes, these buttons disappear. If there are relevant events, I can listen to the events and re-add these buttons.

Im not aware of such an event. One thing you could try would be to poll the active editor windows and detect changes.
Using something like FindObjectsByType to find the windows.
We also have an internal list of Editor windows you could access with reflection although anything internal can change at any point.

1 Like

I recently took a cursory look at the source code related to setting the layout, but I did not see the relevant callback.
I’m currently working on a small tool, and keeping a monitoring for it would be too heavyweight. Given that resetting the layout is a low-frequency operation, I think I’ll leave it alone. If there are similar requirements in the future, I will consider doing it that way.

Thank you for your suggestion!

1 Like