I am using a textfield for getting the name of the player.
Pname = GUI.TextField (Rect (300, 350, 400, 50), Pname, 25, myStyle);
However, I have a problem with it. The player can also press enter to go to a new line. This causes a glich in my save system. Is there any way disable the enter, and the new line?
Answer by Waz
Aug 30, 2011 at 10:58 AM
That's odd. TextField shouldn't allow newlines, only TextArea.
You could remove them from Pname with String.Replace:
Pname = Pname.Replace("\n"," ");
This has solved the problem, thanks! :)
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
4 People are following this question.
when button pressed, textfield appears
Display additional text before the variable that the user is editing in a GUI Text Field
Suppress Autocorrect in GUI.TextField
GUI textfield duplicate text
GUI Textfield not accepting input once Compiled