Hi all,
I have a script that uses the iPhoneKeyboard that's causing me a few problems, any suggestions would be appreciated.
Both ways that I have a tried have a problem which are no doubt the same thing, quite simply either the keyboard doesn't pop up correctly or the text doesn't input. I'm pretty sure it's just where the coroutine isn't yielding properly. The only reference I could find to iphone keyboard was in Javascript.
My first script looked like this:
using UnityEngine;
using System.Collections;
public class s_NameEntry : MonoBehaviour {
private string name;
private bool isTyping = false;
void Update ()
{
if(s_GameManager.gameState == s_GameManager.GameState.name && isTyping == false)
{
isTyping = true;
StartCoroutine(TextInput());
}
}
IEnumerator TextInput()
{
iPhoneKeyboard keyboard;
keyboard = iPhoneKeyboard.Open(name);
yield return keyboard;
name = keyboard.text;
PlayerPrefs.SetString("Player Name",name);
isTyping = false;
}
}
My second script looked like this:
using UnityEngine;
using System.Collections;
public class s_NameEntry : MonoBehaviour{
private string name;
private bool isTyping = false;
void Update ()
{
if(s_GameManager.gameState == s_GameManager.GameState.name && isTyping == false)
{
isTyping = true;
StartCoroutine(TextInput());
}
}
IEnumerator TextInput(){
iPhoneKeyboard keyboard;
keyboard = iPhoneKeyboard.Open(name);
if(keyboard.done)
{
yield return keyboard;
name = keyboard.text;
PlayerPrefs.SetString("Player Name",name);
isTyping = false;
}
}
}
Also tried:
yield return keyboard.done;
In the first version the text area of the keyboard never appears presumably because it keeps creating new ones and in the second one the field 'name' stays blank, presumably because it is set immediately.
For some reason the code isn't formatting properly sorry about that!
Thanks in advance.
Dan