Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This question was closed Mar 13, 2015 at 09:50 PM by TommiH for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by TommiH · Feb 16, 2015 at 05:56 PM · androidpausekeyboardhang

Android keyboard pauses app, and doesn't release it

Hello.

I'm confused by the workings of the Android keyboard. When opened, it seems to pause the Unity execution (no Update functions getting called etc). That would be acceptable (though not optimal, because I want to show the typed text in a text field), but it doesn't even seem to release this lock when closed!

Below is a very simple bit of example code. If I run this on the Android device, I get debug lines only up to the point when I tap the screen to open the keyboard. After that, no matter what I do, it never gets into the Update function again. Except, if I press the Home button and resume the app via multitasking, it does resume.

 public class AnroidKeyboardTester : MonoBehaviour {
 
     private TouchScreenKeyboard keyboard;
 
     public void Update(){
         Debug.Log("Update: " + Time.frameCount);
         if (Input.GetMouseButtonDown(0)){
             keyboard = TouchScreenKeyboard.Open("test", TouchScreenKeyboardType.Default, false, false, false, false);
         }
     }
 }

Edit: one line does appear in the log once I press the "OK" button on the Android keyboard:

windowFocusChanged: true

It changes to false when I open the keyboard. So I think this focus is supposed to change back, but it's not actually changing...

Comment
Add comment · Show 3
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
avatar image pako · Feb 16, 2015 at 06:53 PM 0
Share

I think you're supposed to use the keyboard inside OnGUI() not in Update(), but I haven't tested it.

avatar image TommiH · Feb 23, 2015 at 12:01 PM 0
Share

Thanks for the suggestion. I tested it, however, and it doesn't seem to make a difference.

avatar image TommiH · Mar 13, 2015 at 09:51 PM 0
Share

Looks like they fixed it in Unity 5.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by skylem · Feb 23, 2015 at 12:11 PM

here you go buddy, u just need to switch it on/off using a lone boolean the following should work for you

 if(Input.GetMouseButtonDown(0) && !kb)  {
    kb = true;
 }
 else if(Input.GetMouseButtonDown(0) && kb)  {
    kb = false;
 }
 
 if(kb) {
              keyboard = TouchScreenKeyboard.Open("test", TouchScreenKeyboardType.Default, false, false, false, false);
 
 }
 

u will probably need some additional code(my knowledge on touchscreen technology is virtually non existant) however i have noticed that there is also

 TouchScreenKeyboard.visible = true/false;
 

perhaps this is useful to ur situation. if it doesn't work let me know and i'll do some research.

Comment
Add comment · Show 4 · 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
avatar image TommiH · Feb 23, 2015 at 12:19 PM 0
Share

Thanks for the suggestion. I'll try that later just to be sure, but I don't see how that could work, since the program never gets into the Update function again once it has opened the keyboard. (So it would never get to the point where it switches kb back to false.

avatar image skylem · Feb 23, 2015 at 12:49 PM 0
Share

ah i totally forgot about that issue when i wrote my answer, yes i meant to suggest that if update is failing assu$$anonymous$$g u have tried FixedUpdate and LateUpdate aswell rather then initiate your keyboard use StartCoroutine and see if this is also failing an example of coroutine below

     void Update () {
         if(!kb || kb) {
             StartCoroutine(Jump());
         }
     }
 
     IEnumerator Jump () {
         if(!kb) {
             Debug.Log("Off");
         }
         
         if(kb) {
             yield return new WaitForSeconds(0.5f);
             Debug.Log("On");
         }
     }
avatar image skylem · Feb 23, 2015 at 12:56 PM 0
Share

applogies totally forgot about that issue while i was writing my answer i meant to suggest a coroutine example below

     void Update () {
         if(!kb || kb) {
             StartCoroutine(Jump());
         }
     }
 
     IEnumerator Jump () {
         if(!kb) {
             Debug.Log("Off");
         }
         
         if(kb) {
             yield return new WaitForSeconds(0.5f);
             Debug.Log("On");
         }
     }

it is odd that Update is Failing i've literally never encountered this issue which surprises me i suggest testing on multiple devices just to be sure that your device is not the cause of the problem, i don't know why it would be but it is certainly possible.

avatar image TommiH · Feb 26, 2015 at 10:10 PM 0
Share

I tested all of FixedUpdate, Update, LateUpdate, and a coroutine. None of them are executed after the Android keyboard opens.

Also (added to main question too): one line does appear in the log once I press the "O$$anonymous$$" button on the Android keyboard:

windowFocusChanged: true

It changes to false when I open the keyboard. So I think this focus is supposed to change back, but it's not actually changing...

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

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

iOS / Android OnApplicationPause: incoming calls vs home button 1 Answer

Android Soft Keyboard and hideInput 0 Answers

Android Keyboard English Only? How? 1 Answer

Android keyboard pushes scene up. 2 Answers

Controlling pause menu with keyboard in Unity 4.6? 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