Problem - white textbox dissappear only when press on "done" key on iphone keyboard

Hi,

I’m using a GUI.TextField to input the name of the player.
The GUI.TextField is hidden by the iphone keyboard when I open it, that causes an big white rectangle (text box) to appear on top of the keyboard with the text in it.

If you press the button done, the keyboard closes and the textbox dissappear. If you press the close keyboard key (probably hide keyboard in fact) it only closes the keyboard not the textbox so you have to touch the textbox to reopen the keyboard and close it with the done button.

How can I avoid that issue ? (I can’t move my GUI.TextField, layout-wise).

Is there a way of blocking the “close keyboard” button? What opens that text box, IOS or Unity?

Thanks for the help

Anyone has a clue about that?

Which version of Unity are you using? I seem to recall a bug involving TextField, iOS, and Unity 3.5.

I would hope it had been addressed in the latest update, but it might not have been.

I’m using Unity Pro 3.5.2f2 + IOS Pro.

I try to keep a list of bugs I run into while using Unity. This seems to be the issue:

  • Text Area not working properly on IOS. If the user minimizes the keyboard, the text area gets stuck on screen.

  • Text Field sometimes behaves like Text Area on iOS, particularly if using a GUIStyle instead of a GUISkin.

I believe my work around for this was to use TextField instead of TextArea, and use a GUISkin rather than a GUIStyle.

There is (was?) also a related issue with split keyboards not getting placed properly, but fortunately most users won’t use this feature.

ok problem solved by using that:

GUI.BeginGroup(new Rect());
GUI.skin.textField = TextRXXL;
Name = GUILayout.TextField(Name,8);
GUI.EndGroup();

Thanks a lot for your help

Hum there is one problem. You need text in the textfield to open the keyboard… is there a way to change that ?

At the moment a added a line if(Name == “”) Name = “Insert your name”;
but is there a way to avoid that ?

iPhoneKeyboard.Open might do the trick.

If you aren’t too close to release I would suggest making the switch to one of the many third party GUI frameworks available. There are free ones, or others that are available for a small price.

Unitys GUI is quite expensive performance wise (for mobile devices), and there are a few situations it doesn’t handle very well at all (e.g. complex fonts/text displays).

I did a button at the same place as the textfield with iPhoneKeyboard.Open(Name);

It only update the Name string when I click done, if I press enter or close keyboard it doesn’t work. Not sure what to do, my "if(Name == … "still work I probably leave it as it is, unless you have an idea don’t worry ;).

Thanks a lot for the help anyway :smile:

I’ve got very few guis and I’m working on the game since 9 months release in less than 4 weeks :slight_smile: erf ^^

I’ll use NGUI for the next game

Heh yeah a bit late :slight_smile:

There is no reason to use a third party framework if your GUI is relatively simple. Trust me, any modern iOS/Android device can handle a few OnGUI() calls.

I know it can work, I released Dicey Dice before I really understood much about Unity/OpenGL/iOS, although its not OnGUI it uses GUITextures for everything, and its playable on a 3G (although 3GS is recommended).

But for most projects draw calls are a precious resource, not to mention your users battery life. Unless you plan for all of your projects to be simple you might as well make the switch sooner rather than later. Not only will you gain performance boosts, battery savings, and better support for multiple resolutions, most people tend to agree that they are easier to work with than Unity’s own GUI.

Long term the only reason not to switch for a new project (as far as I can see) would be maybe holding out for Unity’s next GUI release (assuming existing knowledge will transfer).

I’m not saying switch to the OP, he’s nearly done, his project works (minus these bugs he is sorting out). That’s fine.

Anyways getting way off topic, hope the OP doesn’t mind :s

Current mobile hardware can easily do 100-200 draw calls at 30 fps.

If you’re batching other materials, you’ll have plenty of draw calls for the GUI.

Also consider that the most complex GUI will likely be a main menu and/or in-game menu. Since the game isn’t running during the former, and likely paused during the latter, draw calls and frame rate are irrelevant (as long as your buttons are responsive).

I found nice GUI animation done with NGUI, in this project I’ve got a very little amout of GUI mainly text(scores, combos left, time left, top name), everything else in the HUD is done with 3D objects with pngs. But transparency, isn’t that good neither. I’ve learnt a lot with this game (my first game(not mini-game)) and I’m looking forward for the next one, it will be even more efficient!!

Btw if you like challenges, I’m trying to solve another bug here, I’ve put a new test scene ^^

Nothing to do with GUIs but same game :smile:

Challenging bug

Sorry to advertise my own topic!

Given that the OP doesn’t seem to mind our thread hijacking … .:slight_smile:

I agree with what you have said (TonyD). However my point of view is:

  • there is very unlikely to be an issue in using a well supported, commonly used, library which provides source code
  • the features in UI extensions are better than Unity’s GUI (an opinion but well supported by the community)
  • most games have GUI components during gameplay and OnGUI is still expensive enough to affect performance in some cases, maybe not very often on current devices, but on devices one or two generations old

Have you had a good look at NGUI (its free for review/trial/educational/asset store purposes now)?

** DISCLAIMER ** For my own released projects I have used my own GUI framework, but for newer (work in progress) I have transitioned. For commercial work I always recommend a UI toolkit.

EDIT: Removed stuff about your opinion. I don’t think it was rude but no need for me to put words in your mouth :slight_smile:

I still have a problem with that in fact… As explained earlier, I’ve got a button and a textfield at the same place, because the textfield opens the keyboard only if you press on the text itself not the empty part of the textfield, so the button opens the keyboard to edit the string Name.

When I press on the button (not on the text) it does open the keyboard with the Name string in it, but when you edit it, it doesn’t change anything, Name modified in the keyboard opened by the button (not the textfield) isn’t saved and is basically useless…
The only modification updated on screen and in the script is the one applied with the keyboard opened by clicking on the textfield (on the text).

Any ideas why and how can I change that ?