How to draw certain gizmos only in Scene view, but not in Game view

I am using OnDrawGizmos() with Gizmos turned on in game view, which is great and exactly what I want, but I want to draw some lines in Scene view, while not drawing some in Game view. Basically, what I need is a way to detect that current window being drawn is Game view. Is there such a function?

Basically, if I want to draw both rays in Scene editor, but only draw the vertical line in Game view:

void OnDrawGizmos()
        {
            Gizmos.DrawRay(Vector3.zero, Vector3.up);

            if (!IsInGameView()) // Is there something like this???
                Gizmos.DrawRay(Vector3.zero, Vector3.right);
        }

Haven’t tested this, but maybe SceneView.currentDrawingSceneView could work.
Something like this?

if(SceneView.currentDrawingSceneView == null) {
  //There are currently no scene views being displayed.
}

This will only work if you don’t have both the scene and game views visible at the same time.

Edit:

Found a likely better solution with Application.isFocused.
According to its documentation:

Thanks! Application.isFocused works well when only one window is visible, but as you mentioned, not when both windows are active side by side. When you click in a Game view it becomes focused and the gizmos disappear in scene view. SceneView.currentDrawingSceneView has the same effect.

Edit: Correction, actually SceneView.currentDrawingSceneView == null is exactly the IsGameView() that I need :slight_smile: