Search Unity

[Editor] is window open(and visible)?

Discussion in 'Scripting' started by BinaryCats, Feb 14, 2020.

  1. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    238
    Hello,

    Is there a way to know if an EditorWindow (in my case SceneView) is open and visible?

    I can not use
    GetWindow
    as a do not want to open the window
    I can not use
    HasOpenInstances
    as this will return true, if the window is hidden by another tab in the same dock

    Thanks
     
  2. wileyjerkins

    wileyjerkins

    Joined:
    Oct 13, 2017
    Posts:
    58
    Is this a game? Here is how I tell if an enemy is visible on the screen.
    Code (CSharp):
    1. public static bool IsVisibleToCamera(Camera MainCamera, Transform transform)
    2.     {
    3.         if (MainCamera.enabled != true) { return false; }
    4.         if (transform == null) { return false; }
    5.         Vector3 V = MainCamera.WorldToViewportPoint(transform.position);
    6.         return (V.x >= 0 && V.y >= 0) && (V.x <= 1 && V.y <= 1) && V.z >= 0;
    7.     }
     
  3. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    238
    No this an editor utility
     
unityunity