Docked editor windows don’t seem to get OnFocus/OnLostFocus events as you switch between tabs. Is there a workaround anyone would like to share?
There might be a dirty workaround:
class DemoEditorWindow : EditorWindow {
private bool _focused;
private void OnFocus() {
_focused = true;
}
private void OnLostFocus() {
_focused = false;
}
private void Update() {
// Did get focus?
if (this == focusedWindow) {
if (!_focused)
OnFocus();
}
else if (_focused) {
OnLostFocus();
}
}
}
Warning: Not tested! but you should hopefully get my general theory: