- Home /
EditorWindow is visible
Hi, i want to know if there is any way to know if a editor window is visible, for example if you have it attached next to the inspector tab but you are on the inspector tab, is not visible.
Hacky stuff is welcomed.
Example:
Here is the answer: http://www.improck.com/2014/11/editorwindow-onbecamevisible-and-onbecameinvisible/
$$anonymous$$ethods void OnBecameVisible and void OnBecameInvisible are what you're looking for. They are not listed as Editor events, but they do trigger whenever the window is hidden.
Answer by IzzySoft · Jan 09, 2015 at 07:10 AM
bool isGameViewVisible = !(Screen.width == 640 && Screen.height == 480);
Answer by Abu-Faisal · Feb 06, 2016 at 06:15 PM
OnFocus() and OnLostFocus() are what you looking for.
I hate Unity misleading documents.
Sorry for replying to old question, but I faced this issue today and tried to solve it with no luck of googling it.
OnFocus and OnLostFocus do not trigger when the window disappears, it triggers when focus shifts. If you click on any other window in the editor, like the scene window, OnLostFocus will be called and vice versa. OnBecameVisible/OnBecameInvisible are the methods to do it. They aren't even documented as methods used by the Editor, wth?
This needs to be an answer, and accepted! Thanks for finding these callbacks!