- Home /
android textfield problem
When building an android version of my game i have some problems with my textfields. When going from one textfield to an other, the 2nd textfield copies the content of the first.
They are created like this:
user_name = GUI.TextField(new Rect(wi*2, hi*8.1f, Screen.width-(wi*4), hi*2), user_name, 25,maingui.GetStyle("textfield") );
user_email = GUI.TextField(new Rect(wi*2, hi*11.35f, Screen.width-(wi*4), hi*2), user_email, 25,maingui.GetStyle("textfield") );
is there anything i am missing?
Did you ever figure out what was causing this, we're seeing similar behavior
Answer by Bunny83 · Jul 10, 2012 at 06:26 PM
Well, the problem is that Unity uses an internal "TextfieldEditor" class. This is some kind of singleton. There is only one instance since it can only be one active TextField. Usually Unity detects when you click on another field and reinitialize the editor for the new field. I don't develop for iOS, so i can't test it, but maybe you can force a switch by resetting hotControl and keyboardControl when you want to switch.
Btw: If you have set your maingui skin as default skin:
GUI.skin = maingui;
You can just use the style name:
user_name = GUI.TextField(/* ... */, user_name, 25, "textfield");
If you use multiple skins at the same time, you would have to switch the skin every time, which is not very effective.
Your answer
Follow this Question
Related Questions
Popup opened by event. Android 0 Answers
Unity Scale One Text Field GUI 2 Answers
A node in a childnode? 1 Answer
Porting Android Game(developed in Eclipse) to Unity3D 1 Answer
Missing AdActivity with android:configChanges in AndroidManifest.xml 0 Answers