- Home /
My text field is not taking any input
I am writing a GUI application for Unity and I have text box showing which is great but for some reason I can't enter any kind of text into it.
Here is the class:
/// <summary>
/// Main function where the GUI windows are created
/// </summary>
///
void OnGUI()
{
MyFirstWindow();
}
/// <summary>
/// Displays the background survey that the user will fill out
/// </summary>
void MyFirstWindow()
{
int windowWidth = 800;
int windowHeight = 600;
//// Make a background box
GUI.Box(new Rect((Screen.width / 2) - (windowWidth / 2),
(Screen.height / 2) - (windowHeight / 2),
windowWidth, windowHeight),
"Hello World!");
string txtAge = "";
txtAge = GUI.TextField(new Rect(600, 355, 50, 40), txtAge, 2);
}
Your text field is 600 pixels to the right of you box. Is that what you really want? What happens if it's 10 pixels offset in x and y?
no what I want to do to it is to be able to enter text into it
Answer by Patrykgazing · Nov 26, 2013 at 10:14 PM
I'm not C# programmer, but i think that 'string txtAge = "";' doing in MyFirstWindow is causing the problem.. Maybe get it off?
Your answer
Follow this Question
Related Questions
Changing GUI.Box opacity 3 Answers
How to dynamically change the text in Unity(Augmented Reality + NYARtoolkit(C#)) ? 0 Answers
C# how to create a Descending GUI List 1 Answer
Make HUD to show object direction 0 Answers
A node in a childnode? 1 Answer