Hi.
I wonder if you can automatically resize a textfield/label depending on the content, i have looked in the docs but i could not find anything.
(this is for scrolling).
Assuming I understand you right, if you set the StretchWidth and StretchHeight flags in your label style (in the skin), then it will size to fit the content until it fills the available space for that element (assuming you’re using GUI.Layout and not fixed GUI).
Some more tips if you want the window background to change size, too.
-
Set the Window or Area rect to a large value and use a style with no background texture on those elements. I usually constrain the width and let the height stretch but of course you can do it the other way or both.
-
Contain your label element in a Vertical or Horizontal group with the background set.
GUILayout.BeginVertical("style_with_a_background");
GUILayout.Label("My Text", "style_with_no_background");
GUILayout.EndVertical();
well.I have a label (multi row). but sometimes the text in it is larger then the actual label area so it will be clipped, now i want scrollers to appear when the text is larger then the label size. And i’m using fixed gui but i think i can replace that with GUILayout if it’s needed.
OK, then you need to look at a ScrollView to contain your text. Especially with GUI.Layout, they work pretty automagically.