How to get Game View Height from OnDrawGizmos?

I realized recently that calling Screen.width/height from OnDrawGizmos ALWAYS returns the dimensions of the Scene view, probably because gizmos are exclusive to that window. However, is there a convenient method to use to get the Game View’s dimensions from OnDrawGizmos? For now, I’m going to be caching a reference to a camera in the game view, and using the pixelWidth/pixelHeight values from that, but if there’s a better way, I’d be interested in hearing it!

Super old post, but maybe some people are helped by the answer.

-

You could use “Screen.currentResolution” which gives back the current setting as depicted in the GameView.

-

Another solution is covered by this post using reflection