I’m using the following line in my code to allow the user to enter a profile-name:
MainGame.MyProfileName = GUI.TextField (new Rect(Screen.width/2-125*myGUIScale,Screen.height/2, 250*myGUIScale, 20*myGUIScale), MainGame.MyProfileName, 16, myStyle);
When I look at the description of the GUI.Textfield, it tells me “Make a single-line text field where the user can edit a string.”, but when I test the code in the Unity editor it allows me to use the ENTER key to make multiple lines, and when I display the MainGame.MyProfileName, it shows the ENTERs as well.
Is there any way to avoid people from using the ENTER key when using GUI,TextField?
Is this a bug? It’s been happening to me while trying to write a KSP plugin. I have searched and searched and cannot find a proper solution. By which I mean using Event’s Use or something like that. I feel I should not have to add extra variables to handle intercepting the return key, or extra method calls to trim the string, etc.