- Home /
Creating a fancy textbox
I'm making a "menu" with Unity, and I'm looking to display a textbox with some text in it (Say, two or three paragraphs). Think on the Deus Ex text boxes or the Baldur's Gate dialogue boxes. Scroll is optional (As the information I want to add on it should fit the original "frame"), but it would be an interesting add-on.
Giving I'm kind of a newb in Unity, I've only come out with a solution using a GUITexture together with a GUIText: The Texture "behind" the text, so it appears as everything is one single object, but I'm finding not very intuitive having to "manually" measure the size of the text and then adapt the GUITexture to it.
So, the question is: There is any (free) and "direct" way to make a fancy textbox in Unity, or should I just code it myself?
Answer by Jamora · Jun 07, 2013 at 08:02 AM
Unity offers a "ScrollView" (http://docs.unity3d.com/Documentation/ScriptReference/GUI.BeginScrollView.html) as part of its built-in GUI-arsenal. Bascially what you need is
void OnGUI () {
// Begin the ScrollView
scrollViewVector = GUI.BeginScrollView (new Rect (25, 25, 100, 100), scrollViewVector, new Rect (0, 0, 400, 400));
// Put something inside the ScrollView
innerText = GUI.TextArea (new Rect (0, 0, 400, 400), innerText);
// End the ScrollView
GUI.EndScrollView();
}
Have a look at the other GUI possibilities at http://docs.unity3d.com/Documentation/Components/GUIScriptingGuide.html
Yup, that was pretty much it. I'm using a Label ins$$anonymous$$d a TextArea, but it's working, thanks!
Your answer
![](https://koobas.hobune.stream/wayback/20220613103701im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer
Some GameObjects can't touch !!! 0 Answers
Problem vid GuiTexture 0 Answers
How do I make a border decoration effect? 1 Answer
"Top" Depth only camera Culling effects bottom camera 0 Answers