- Home /
Inserting text into GUILayout Box?
Hello. I've a problem putting in text into my GUILayout box. Here is my script:
function OnGUI()
{
GUILayout.BeginArea( Rect( 2, Screen.height 50, 50, 55 ), "Testt", GUI.skin.window);
guiText.text.enabled("Hello"); guiText.pixelOffset = Vector2 (30, 20);
GUILayout.EndArea();
}
I have other functions inside the box as well, not shown here. I just want to put in a text for display purposes only; no functions whatsoever.
This script can't be compiled; what am I doing wrong?
Answer by Nolirneen · Mar 21, 2011 at 03:45 AM
Ok, I've found a solution - add a label inside the GUIbox.
function OnGUI()
{
GUILayout.BeginArea( Rect( 2, Screen.height 50, 50, 55 ), "Testt", GUI.skin.window);
GUI.Label (Rect (30, 100, 100, 30);
GUILayout.EndArea();
}
I realised that the few sets of numbers in the brackets are coordinates for where the GUI is to be placed. =)
Answer by Lab013 · Mar 18, 2011 at 06:30 AM
If I might recommend you take a look at the GUI documentation, GUILayout documentation, and GUI tutorial in Unity's Documentation, I think that'd help you out a lot. That being said, I think this is what you wanted to do:
function OnGUI()
{
GUILayout.BeginArea( Rect( 2, Screen.height 50, 50, 55 ), "Testt", GUI.skin.window);
GUILayout.Text("Your text here!");
GUILayout.EndArea();
}
Assets/Scripts/$$anonymous$$enus+gui/$$anonymous$$ain_menu.js(16,15): BCE0019: 'Text' is not a member of 'UnityEngine.GUILayout'.
Answer by E2R_Ben · Jun 20, 2012 at 01:44 PM
I think you might want to use this:
GUILayout.TextArea ( "Hello World\nI've got 2 lines...", 200);
See http://unity3d.com/support/documentation/ScriptReference/GUILayout.TextArea.html
Your answer
Follow this Question
Related Questions
HELP with scripting where GUI is involved 2 Answers
Bullet Points 1 Answer
changing font + size of text 1 Answer
Can't add a GUI in C#?? 1 Answer
How to set different alignments to differenent lines of text in one field of text 0 Answers