|
Im using a Gui.Textfield as an input Textfield. In the reference they write it is a single Line Textfield. But it still allows a "\n" as input. Do i miss something, or do i have to use a Regular Expression or String.replace("\n", "") to prevent the String to be Multilined? Or is there even a better way?
http://unity3d.com/support/documentation/ScriptReference/GUI.TextField.html
(comments are locked)
|
|
I got this problem too. But in my case,I set a custom style to TextField. I don't know why it allows multiple lines, my custom style only changed Textures.
(comments are locked)
|
|
In my little test, the only way I could get the textfield to have multiple lines is if I set the start string to have a newline in it and don't escape it (either through \\n or using the @ syntax). I tested it with typing in \n and it didn't create a newline or anything. I'm assuming that it escapes special characters like \. In my case, my Textfield starts with an empty string. And it still allows multilines. Right now i solve the issue with [value = value.Replace("n", "").Replace("r", "");].
Jun 22 '10 at 07:43 PM
Case23
(comments are locked)
|
|
The only thing I have found is to use replace string as Case23 said
There is an old post talking about it here http://forum.unity3d.com/viewtopic.php?p=257819 AngryAnt has a good idea(Event.current), but I have not had any luck with it. That'd be because the logic is wrong in it. It'd need to be something more like (in pseudocode).:. if((type == keyup || type == keydown) && (keycode == KeyCode.Return || keycode == KeyCode.KeypadEnter))
Aug 02 '10 at 10:10 AM
Mike 3
I've tried quite a few combo's and could not get it to work at all :(
Aug 02 '10 at 11:16 AM
Usul
Sorry to dig up this old question but I'm having the same problem and it's ruining a lot in my game :( Anyone have any ideas?
Aug 12 '12 at 02:26 AM
SomeGuy22
@SomeGuy22 try using TextArea with the same arguments (maxLength + style)? I've found it to be single-lined for no reason and wondering if other people's having the problem too.
Nov 23 '12 at 03:50 AM
caroparo
(comments are locked)
|
|
If you want more control over the touch keyboard, don't use a TextField at all. On mobile devices you always have to use the native keyboard which displays it'a own input field above your Unity application. So it's way easier to replace the TextField with a Button and simply open up the keyboard with the desired settings:
(comments are locked)
|
