How to get inspector size / rect for Custom Editor?

Hi!

I know two ways to get the width of the visible area of the inspector window:

(float)typeof(EditorGUIUtility).GetProperty("contextWidth", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).GetValue(null, null);
EditorGUIUtility.currentViewWidth;

But it does return the width, including the scrollView if it has one (some of my content is overlapping the scrollView).
I could draw the scroll myself when I need to, but the problem is that I can’t get the height!

I can calculate the width using GUILayoutUtility.GetRect but in the first lifecycle it returns Rect(0,0,1,1)
And when the window is resized, the GUILayout methods fall behind. It looks terrible.

How do I get the size of the inspector window?

Right now I’m using this crutch:

var width = EditorGUIUtility.currentViewWidth;
var height = Screen.height * (width / Screen.width) - 160;

160 = Inspector title height + Assets labels (for ScriptableObject)

I know it’s a year too late, but in case someone else needs the answer! I’m using these, so I THINK these work…

float EditorWindowWidth = position.width;
float EditorWindowHeight = position.height;

Possible Alternatives:

float EditorWindowWidth = position.xMax;
float EditorWindowHeight = position.yMax;