GUILayout.BeginScrollView - get maximum scrollPosition.y value?

Hello,

Im struggling to retrieve the maximum value the scroll position of GUILayout.BeginScrollView on the y axis.
Inside the ScrollViews, there are labels (its going to be a chat).

Each Label comes with a GUILayout.Space(-8) after it.

Since the GUI is not static but the rects are created according to the screen resolution, I can’t just put some fixed formula to get the maximum scroll position (tried that, of course it went wrong when changing resolution).

So what I have tried is to add all the label heights together, but the result is not correct.

ytotal += GUI.skin.label.CalcSize(new GUIContent(msg.Message)).y - 8f;

is what I used to calculate it. In my tests, it always gave me 338 but when i scrolled down on different resolutions, the scrollPosition.y value differed from that.

How can I solve that problem?

watching