Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

unity input control - making keyboard slide from below

Discussion in 'Scripting' started by beez-dev, Dec 8, 2021.

  1. beez-dev

    beez-dev

    Joined:
    Aug 13, 2021
    Posts:
    47
    I have an android app built from unity, and it uses a Text Mesh Pro input field. The problem I have is that, when the user wants to type in the input field, this sort of interface pops up:



    upload_2021-12-8_18-46-35.png

    So, the user has to click the input field, type his text, disable the keyboard by clicking somewhere on the screen and then press the send button in the app to send the message.

    i.e. the keyboard overlays on top of the input field, so the user cannot press the send button after he's done typing?



    How, do we make the keyboard appear like this?:



    i.e. it slides in from beneath, pushing the input field upwards while typing?
     

    Attached Files:

  2. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,653
    Well, using the TouchScreenKeyboard class, you can use hideInput to as the name suggests, hide the default input field, and also use the area property to find out how large the keyboard is and place your input field above it.
     
  3. Serge_Billault

    Serge_Billault

    Joined:
    Aug 26, 2014
    Posts:
    190
    You are right, setting TouchScreenKeyboard.hideInput to true when you provide your own input fields, and to false when you do not, is too simple.

    I will second you if you decide to contact the devs and request that additional steps need be performed instead:
    * Wait for a full moon
    * Perform a belly dance with 13,5 ninjas around a camp fire
    * While a guru plays yukulele and sing in reverse
    * The button must go to the next level (it must be a level 2 button)
     
    beez-dev likes this.
  4. beez-dev

    beez-dev

    Joined:
    Aug 13, 2021
    Posts:
    47
    does that mean placing the input field should be done programmatically (manually) i.e. unity doesn't handle it automatically?
     
  5. beez-dev

    beez-dev

    Joined:
    Aug 13, 2021
    Posts:
    47
    I also did this and it didn't work:
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class inputScript : MonoBehaviour
    7. {
    8.    
    9.     void Start()
    10.     {
    11.         TouchScreenKeyboard.hideInput = true;
    12.     }
    13.  
    14. }
    15.  
     
  6. beez-dev

    beez-dev

    Joined:
    Aug 13, 2021
    Posts:
    47
    I actually logged it, in `Start()` and also in a coroutine using `WaitForEndOfFrame()` but, they both spat ` The touch screen area height is: (x:0.00, y:0.00, width:0.00, height:0.00)` for TouchScreenKeyboard.area;

    I wonder if the ritual mentioned by Serge is actually true.