1
NGUI 3 Support / Re: Keyboard of Windows Store
« on: June 24, 2014, 12:12:00 PM »
Hey Guys,
So I ran into the same problem posted above and by combining information from: http://forum.unity3d.com/threads/unity-4-5-windows-store-touch-screen-keyboard-not-working.248523/#post-1650855 and what was posted here, the edits I made to UIInput.cs (NGUI version 3.5.5) were as follows:
in OnSelectEvent()
In the Mobile Update() function
The limitations of this solution are that the only special keystrokes I could recognize were backspace. But it did allow us to write a simple register/login UI for our game. I hope this helps others with the same problem!
~Andrew
So I ran into the same problem posted above and by combining information from: http://forum.unity3d.com/threads/unity-4-5-windows-store-touch-screen-keyboard-not-working.248523/#post-1650855 and what was posted here, the edits I made to UIInput.cs (NGUI version 3.5.5) were as follows:
- //Change definition of mobile to include UNITY_WINRT (Metro + WP8 )
- #if !UNITY_EDITOR && (UNITY_IPHONE || UNITY_ANDROID || UNITY_BLACKBERRY || UNITY_WINRT)
in OnSelectEvent()
- //Replace just adding the application.platform for WP8Player
- #if UNITY_WINRT
- || Application.platform == RuntimePlatform.WP8Player
- || Application.platform == RuntimePlatform.MetroPlayerARM
- || Application.platform == RuntimePlatform.MetroPlayerX64
- || Application.platform == RuntimePlatform.MetroPlayerX86
- #endif
- ...
- mKeyboard = (inputType == InputType.Password) ?
- TouchScreenKeyboard.Open(mValue, TouchScreenKeyboardType.Default, false, false, true) :
- TouchScreenKeyboard.Open(mValue, (TouchScreenKeyboardType)((int)keyboardType), inputType == InputType.AutoCorrect, label.multiLine, false, false, defaultText);
- //This is the only way the keyboard knows to be opened.
- #if UNITY_METRO
- mKeyboard.active = true;
- #endif
In the Mobile Update() function
- #if MOBILE
- string mCached = "";
- void Update()
- {
- #if UNITY_METRO
- if ( isSelected )
- {
- string text = Input.inputString; //According to the unity forum, only way to detect key presses
- if( !String.IsNullOrEmpty(text) )
- {
- if( text == "\b" ) //The only way to pick up on the backspace from Input.inputString
- {
- if( !String.IsNullOrEmpty(mCached) && !String.IsNullOrEmpty(value) )
- {
- mCached = mCached.Remove(mCached.Length - 1, 1);
- value = value.Remove(value.Length - 1, 1);
- }
- }
- else
- {
- //Since mKeyboard.text is always null, you have to accumulate the chars
- //found at the frame they are processed
- mCached += text;
- value += text;
- }
- }
- }
- }
- #else
- ... //rest of the Mobile update function
The limitations of this solution are that the only special keystrokes I could recognize were backspace. But it did allow us to write a simple register/login UI for our game. I hope this helps others with the same problem!
~Andrew
