Skip to main content
added 113 characters in body
Source Link
Justin Markwell
  • 2.2k
  • 2
  • 13
  • 16

Forcing the keyboard to stay open may not be the best method as on some mobiles the keys will take up a good portion of the available screen space. If a user cannot un-focus the board it could lead to a bad experience for them.

With that suggestion out of the way you do not have to write a custom plugin to achieve the behavior you want. You can set up a boolean to store when you are completed with the keyboard(enter key or some other means). That way you can keep it in Focus until you are done by utilizing the scenes EventSystem.

using UnityEngine.EventSystems;
using UnityEngine.UI;
public class YourClass : MonoBehaviour

public InputField inputField;
bool completedInput = false;

For example you can set the focus using

 EventSystem.current.SetSelectedGameObject(inputField.gameObject, null);

you can auto open the keyboard if needed with

inputField.ActivateInputField();

in combination with a completed boolean you could keep the board open by resetting the focus to the input if someone clicked out of the element or the inputfield is unfocused by other means before they are done.

 if(!completedInput)
        EventSystem.current.SetSelectedGameObject(inputField.gameObject, null);

another way that may prove useful is to check if you are not over a EventSystem object then either null their new selection or something along those lines.

if (!EventSystem.current.IsPointerOverGameObject())
    //do something 

note that you can assign various keyboard layouts in codebehind or in the properties of a input field in the inspector.

inputField.contentType = InputField.ContentType.Autocorrected;

InputField Inspector View

Forcing the keyboard to stay open may not be the best method as on some mobiles the keys will take up a good portion of the available screen space. If a user cannot un-focus the board it could lead to a bad experience for them.

With that suggestion out of the way you do not have to write a custom plugin to achieve the behavior you want. You can set up a boolean to store when you are completed with the keyboard(enter key or some other means). That way you can keep it in Focus until you are done by utilizing the scenes EventSystem.

using UnityEngine.EventSystems;
using UnityEngine.UI;
public class YourClass : MonoBehaviour

public InputField inputField;
bool completedInput = false;

For example you can set the focus using

 EventSystem.current.SetSelectedGameObject(inputField.gameObject, null);

you can auto open the keyboard if needed with

inputField.ActivateInputField();

in combination with a completed boolean you could keep the board open by resetting the focus to the input if someone clicked out of the element or the inputfield is unfocused by other means before they are done.

another way that may prove useful is to check if you are not over a EventSystem object then either null their new selection or something along those lines.

if (!EventSystem.current.IsPointerOverGameObject())
    //do something 

note that you can assign various keyboard layouts in codebehind or in the properties of a input field in the inspector.

inputField.contentType = InputField.ContentType.Autocorrected;

InputField Inspector View

Forcing the keyboard to stay open may not be the best method as on some mobiles the keys will take up a good portion of the available screen space. If a user cannot un-focus the board it could lead to a bad experience for them.

With that suggestion out of the way you do not have to write a custom plugin to achieve the behavior you want. You can set up a boolean to store when you are completed with the keyboard(enter key or some other means). That way you can keep it in Focus until you are done by utilizing the scenes EventSystem.

using UnityEngine.EventSystems;
using UnityEngine.UI;
public class YourClass : MonoBehaviour

public InputField inputField;
bool completedInput = false;

For example you can set the focus using

 EventSystem.current.SetSelectedGameObject(inputField.gameObject, null);

you can auto open the keyboard if needed with

inputField.ActivateInputField();

in combination with a completed boolean you could keep the board open by resetting the focus to the input if someone clicked out of the element or the inputfield is unfocused by other means before they are done.

 if(!completedInput)
        EventSystem.current.SetSelectedGameObject(inputField.gameObject, null);

another way that may prove useful is to check if you are not over a EventSystem object then either null their new selection or something along those lines.

if (!EventSystem.current.IsPointerOverGameObject())
    //do something 

note that you can assign various keyboard layouts in codebehind or in the properties of a input field in the inspector.

inputField.contentType = InputField.ContentType.Autocorrected;

InputField Inspector View

Source Link
Justin Markwell
  • 2.2k
  • 2
  • 13
  • 16

Forcing the keyboard to stay open may not be the best method as on some mobiles the keys will take up a good portion of the available screen space. If a user cannot un-focus the board it could lead to a bad experience for them.

With that suggestion out of the way you do not have to write a custom plugin to achieve the behavior you want. You can set up a boolean to store when you are completed with the keyboard(enter key or some other means). That way you can keep it in Focus until you are done by utilizing the scenes EventSystem.

using UnityEngine.EventSystems;
using UnityEngine.UI;
public class YourClass : MonoBehaviour

public InputField inputField;
bool completedInput = false;

For example you can set the focus using

 EventSystem.current.SetSelectedGameObject(inputField.gameObject, null);

you can auto open the keyboard if needed with

inputField.ActivateInputField();

in combination with a completed boolean you could keep the board open by resetting the focus to the input if someone clicked out of the element or the inputfield is unfocused by other means before they are done.

another way that may prove useful is to check if you are not over a EventSystem object then either null their new selection or something along those lines.

if (!EventSystem.current.IsPointerOverGameObject())
    //do something 

note that you can assign various keyboard layouts in codebehind or in the properties of a input field in the inspector.

inputField.contentType = InputField.ContentType.Autocorrected;

InputField Inspector View