Search Unity

How to detect which tab is focused

Discussion in 'Editor & General Support' started by Dezeris85, Dec 22, 2019.

  1. Dezeris85

    Dezeris85

    Joined:
    Dec 16, 2016
    Posts:
    24
    I was wondering is there a way to detect which of my tabbed windows is currently up front and showing. Like If I have my Inspector window and a custom window tabbed together in the same area and I have the custom window showing and the inspector isn't....is there a way in code to tell?
     
  2. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,317
    You can detect if your editor window is open via OnEnable. If you switch to the Inspector tab and your window disappears as a result, it will call OnDisable.

    You can check what the currently focused window is via EditorWindow.focusedWindow.
     
  3. Dezeris85

    Dezeris85

    Joined:
    Dec 16, 2016
    Posts:
    24
    does not work, enable fires but disable never does until you close the tab... not switching to another