Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Dan 2 · Apr 30, 2010 at 08:31 PM · iphonekeyboardiphonekeyboard

Handling iPhoneKeyboard input c#

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Chris Aardappel · Jan 21, 2011 at 09:19 PM

Hey,

This is a pretty old post so I hope you have had some luck with this. For the record, this is what works for me:

while (keyboard.active) yield return null;

Good Luck!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Camera view changes when opening iPhoneKeyboard. How to make it not change? 0 Answers

Input Text Rotated incorrectly... is this a BUG? 1 Answer

iPhoneKeyboard graphic bug on selecting text 0 Answers

setting iPhoneKeyboard.text (or any workaround about resetting user input) in Android. 0 Answers

How to save text and display using Touch Screen Keyboard 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges