Hi, everyone!
I updated to Unity 4.5 but the touchscreen keyboard doesn’t work yet.
I tried this:
TouchScreenKeyboard keyboard = null;
void Start()
{
keyboard = TouchScreenKeyboard.Open("Oi");
}
Anyone with the same problem?
Hi, everyone!
I updated to Unity 4.5 but the touchscreen keyboard doesn’t work yet.
I tried this:
TouchScreenKeyboard keyboard = null;
void Start()
{
keyboard = TouchScreenKeyboard.Open("Oi");
}
Anyone with the same problem?
+1 - Same problem here. The keyboard displays if I use a GUI.TextField, but not if I try to manually bring up the keyboard similar to what you show in your example.
Anyone having any luck here? Any workarounds?
if (GUI.Button(new Rect(10, 10, 200, 20), “test”))
{
temp = TouchScreenKeyboard.Open(“text”);
temp.active = true;
}
like this
Thanks for the reply!
Well, that did display the keyboard, but I don’t seem to be getting any of the keys. Here’s the sample code I’m using
public class KeyboardTest : MonoBehaviour
{
private string textFieldString = "text field";
private TouchScreenKeyboard keyboard = null;
void OnGUI()
{
if (GUI.Button (new Rect (0, 10, 200, 32), textFieldString))
{
keyboard = TouchScreenKeyboard.Open(textFieldString);
keyboard.active = true;
}
if (keyboard != null)
{
textFieldString = keyboard.text;
}
}
}
With this, the button initially says ‘text field’, but when pressed and the keyboard shows, the text is cleared and isn’t updated when I use the on-screen keyboard.
It just pop up the touch keyborad.But can’t input some key to the text. I used NGUI so i changed some code.
void OnSelect (bool isSelected)
{
if (mDoInit) Init();
if (label != null && enabled && NGUITools.GetActive(gameObject))
{
if (isSelected)
{
mText = (!useLabelTextAtStart && label.text == mDefaultText) ? “” : label.text;
label.color = activeColor;
if (isPassword) label.password = true;
#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY
if (Application.platform == RuntimePlatform.IPhonePlayer ||
Application.platform == RuntimePlatform.Android
#if UNITY_WP8
|| Application.platform == RuntimePlatform.WP8Player
#endif
#if UNITY_BLACKBERRY
|| Application.platform == RuntimePlatform.BB10Player
#endif
)
{
if (isPassword)
{
mKeyboard = TouchScreenKeyboard.Open(mText, TouchScreenKeyboardType.Default, false, false, true);
}
else
{
mKeyboard = TouchScreenKeyboard.Open(mText, (TouchScreenKeyboardType)((int)type), autoCorrect);
}
}
else
#endif
{
Input.imeCompositionMode = IMECompositionMode.On;
Transform t = label.cachedTransform;
Vector3 offset = label.pivotOffset;
offset.y += label.relativeSize.y;
offset = t.TransformPoint(offset);
Input.compositionCursorPos = UICamera.currentCamera.WorldToScreenPoint(offset);
mKeyboard.active = true;
}
UpdateLabel();
}
else
{
#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY
if (mKeyboard != null)
{
mKeyboard.active = false;
}
#endif
if (string.IsNullOrEmpty(mText))
{
label.text = mDefaultText;
label.color = mDefaultColor;
if (isPassword) label.password = false;
}
else label.text = mText;
label.showLastPasswordChar = false;
Input.imeCompositionMode = IMECompositionMode.Off;
RestoreLabel();
}
}
}
You can see the NGUI Uiinput.cs code.
songhaineng, I might be misunderstanding your reply.
Are you saying that with NGUI’s UIInput.cs, it now shows the keyboard, but you still don’t get any typing to show up?
If so, that’s the same problem I’m having.
I’m using NGUI v3.6.2 and I’ve update the code correctly (and posted on the NGUI site), but still don’t get any input.
My previous post is a reduced example where it fails.
Or, are you saying that after you modified UIInput.cs, it shows the keyboard and works?
What is your email?I sent you an example.I used NGUI 2.7!
Wow! It’s easy!
I didn’t notice because on others platforms it’s easier.
One thing I realized is that the code does not work on funcion Start.
And the TouchScreenKeyboard.active = false doesn’t work either!
TouchScreenKeyboard on Windows Store Apps is currently limited to opening the keyboard.
To close it you need to simply focus some non-input control in XAML It closes automatically, when user touches somewhere.
You can get input text from Input.inputString. You’ll have to concat it, as it returns text entered during current frame.
Aurimas, is there a bug then with my example I provided above? The input is not available in my example and it is based on the example provided with the Unity documentation.
TouchScreenKeyboard.text property is not supported on WSA, so it always returns empty string.
Input.inputString returns text, entered during current frame, you can concatenate it.
Hi …thanks for your code…but I’m getting an error which says “mKeyboard does not exist in the current context”…
I guess the only change you’ve made in the defalut code is the mKeyboard.active = true; and the error points to that line itself…
Please help…I have no idea about this problem…
Thanks in advance
From the code it looks like you should replace UNITY_WP8 by UNITY_WINRT.