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);
}
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