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?
3 Answers
3
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();
}
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. =)
I think you might want to use this:
GUILayout.TextArea ( "Hello World
I’ve got 2 lines…", 200);
See http://unity3d.com/support/documentation/ScriptReference/GUILayout.TextArea.html
Hmm I tried this by itself, but it can't compile. =\
– anon49375823What error does it give?
– anon40032747Assets/Scripts/Menus+gui/Main_menu.js(16,15): BCE0019: 'Text' is not a member of 'UnityEngine.GUILayout'.
– E2R_Ben