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 user 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.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
4 People are following this question.
when button pressed, textfield appears
Android Textfield locks out input until esc
GUI custom textfield cursor rendering
Textfield appear on MouseClick
Changing the keyboard type used on a GUI.TextField