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.
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.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
To help users post good questions and use the site effectively we have posted a user guide. Please check it out.
Answers and Comments
4 People are following this question.
Textfield appear on MouseClick
Prevent IOS keyboard from showing
TextField plus Return Key issue
Change the color of a label font that's using an EditorStyle.textField style?
Edit Vector2 values with GUI.TextField