- Home /
Finding the available space in a GUILayout.
Let's say that we've set up a GUILayout area that's 200 by 20 in size and put two horizontal areas within it so that each is (roughly) 200 by 100 in size (but not exact). How can I find out how much space is actually available within each of those horizontal draw areas?
I've tried using GetLastRect but it doesn't seem to do what I want...
Answer by whydoidoit · Jan 13, 2013 at 02:49 PM
GUILayout is designed so that you don't need to know those things! During the repaint phase the GetLastRect immediately after the EndHorizontal will contain the rectangle, but it will be empty during the layout phase - which is where things are positioned.
It would probably help to understand what you are trying to do...
I have built a set of classes that enclose and use GUILayout calls to simplify the creation of lots of dynamic GUI panels. I used GUILayout because it creates a very easy environment to construct complex arrangements of GUI objects on the fly. $$anonymous$$ostly everything will be dynamically sized, sometimes how it would be nice to say that a box should be say 1/3 of the size of the space it has available. I know I can set the box size, but I don't know how to find out what the total space available is...
Answer by Bunny83 · Jan 13, 2013 at 07:11 PM
If you want to distribute the size of an area of a layouted GUI manually, you can use the "normal" GUI. Just use GUILayoutUtility.GetRect to register the whole area and then just use normal GUI elements and arrange them in the Rect as you like.
Your answer
Follow this Question
Related Questions
How to change thickness of ScrollBar of GUILayout ScrollView? 0 Answers
How to set rectangle size in GUILayout 0 Answers
Why can't I get my tooltip to show only when there is a tooltip set? 2 Answers
GUIBox fontSize without changing other labels? 3 Answers
GUI.Window error. InvalidOperationException: Hashtable.Enumerator: snapshot out of sync. 0 Answers