- Home /
Need help creating a scrollable text area for displaying EULA.
I've searched the forum but found no solution for this.
I'm trying to create a simple box / text area to show End User License Agreement (or any long text for that matter. eg. a Help/Tutorial page).
I tried using GUI.BeginScrollView along with textArea. The problem is user can't scroll to the end of the text if the EULA is too long.
Is there some kind of text area that auto-expand itself based on how long the text is?
Thanks in advance!
Answer by lgmcben · Dec 24, 2011 at 07:49 PM
nvm, I've answered my won question with the following code:
var veryLongString = "insert very long text here";
var scrollPosition : Vector2 = Vector2.zero;
scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.MaxHeight(300), GUILayout.ExpandHeight (false));
GUILayout.Label (veryLongString, GUILayout.ExpandHeight (true));
GUILayout.EndScrollView();
This will create an area with 300 height. Scroll bar will appear if the text is too long.
How does this work for Unity 4.5? I find mostly old answers in this Forum. :S
Thanks, this helped me, it also works with TextArea, like this:
GUILayout.TextArea(veryLongString, GUILayout.Width(200), GUILayout.ExpandHeight(true));
and yes - it works in new version of Unity, I'm using it in Unity 5.2.3f1
Your answer
Follow this Question
Related Questions
Suppress Horizontal Scrollbar? 2 Answers
UGUI ScrollRect automatic scroll? (Chat) 1 Answer
Is there a way to scroll GUI text WITHOUT scrollbars? 2 Answers
Scrollview button very small? 0 Answers