I need the resulting Rect for a scrollview I have drawn with GUILayout.
e.g.
scroller = GUILayout.BeginScrollView( scroller );
GUILayout.BeginVertical();
// dynamic run-time data drawn
// in various Verticals/Horizontals
// possibly with FlexibleSpace
GUILayout.EndVertical();
GUILayout.EndScrollView();
Rect scrollArea = ?
Or even:
GUILayout.BeginVertical( "Box" );
// various controls
GUILayout.EndVertical();
Rect boxArea = ?
I know you can use GUILayout.GetRect(…) to “reserve” the space for a single control like a Button–or more specifically for 1 piece of GUIContent–and then call the GUI equivalent with that Rect. But how do you find out how big your scrollview, or styled-BeginHorizontal() is? Even if I rewrite everything to GetRect() and GUI call, I still can’t just union them all together because I’ll need to clip it against the scroll view size, and I don’t think you can get the size of the FlexibleSpace() either.
In case it matters, I need the Rect so I can test dropping items with drag and drop against the screen-space mouse point coords. That works fine already everywhere else, but I at least need a Rect.
As I understand it, you need the size of the clipping rect of the scroll view - not the internal area, right? If this is the case, you can receive the rect like this:
scroller = GUILayout.BeginScrollView( scroller );
GUILayout.BeginVertical();
// dynamic run-time data drawn
// in various Verticals/Horizontals
// possibly with FlexibleSpace
GUILayout.EndVertical();
GUILayout.EndScrollView();
Rect scrollArea = GUILayoutUtility.GetLastRect ();
I have never had any luck with that, and when I was writing this yesterday I noticed it is not in the docs, so I assumed it was broken and had been discretely removed.
I’ll give it a try and let you know.
Thanks!
[Update: Yep, that seems to work perfectly. Now if I can just manage to not obsess over why it didn’t work before, I can try to remember all the things I worked around when it didn’t That will be so useful–thanks!]
And is there any function to get the INTERNAL area rect of scrollview?
That is needed in my project to resize window dynamically when new text appears in it…