EditorWindow OnBecameVisible and OnBecameInvisible

OnBecameVisible and OnBecameInvisible are in the Unity docs as methods of the Renderer and MonoBehaviour classes. It turns out that they work for EditorWindows, too!

They get called when a docked window changes visibility; meaning that when a docked window is hidden by a sibling window within that dock, OnBecameInvisible gets called. Similarly, when the window becomes visible again, of course, OnBecameVisible is called.

There is a little gotcha, though. It seems that both methods get called when docking and undocking the window. Not sure why, really. It’s just another Unity quirk!

Leave a Reply