Advanced Input Field

General Note:
Version 2.0.0 is available on the AssetStore. Current 1.9.* versions will still be updated with bugfixes, but new features will be implemented in version 2 of the plugin. So, if you are starting a new project it’s better to use version 2 of the plugin.

The upgrade to version 2 of the plugin is free for existing users.
Support thread for version 2

Upgrade Notes when upgrading from an earlier version than 1.6.0 to 1.6.0 or newer.:
Following files and directories should be removed before importing new package:

  • Plugins/Scripts/Helper/PointerListener.cs

The format/structure has changed to support both Unity and TextMeshPro Text Renderers. This means that AdvancedInputField instances made with an earlier version than 1.6.0 are deprecated and should be converted with the included ConversionTool (located in the “Advanced Input Field” dropdown).

UWP Note:
Please use XAML as build type, D3D seems to give issues.

General:
While I was developing a mobile app I noticed that default Unity InputField behaved differently than I would expect on Android & iOS. Also there were differences in behaviour on Android & iOS. Some implementations were had to realize, such as filling in a form inside a ScrollRect easily. Pressing the inputfield (to drag inside the ScrollRect) would show the TouchScreenKeyboard, making scrolling inside the ScrollRect annoying.

This plugin started as only a new native binding for the TouchScreenKeyboard, but in the end a reimplementation of the InputField was needed too (to handle some other annoying issues/bugs) and to add new features.

Advanced Input Field:
Asset Store Link

Android samples:
These are builds (apk) of the Sample scenes of the plugin build using the latest version of the plugin.
Samples (Android)

This plugin is a custom implementation of the Unity Input Field (it still inherits from Selectable base class). It adds several features and fixes multiple bugs that were in the original Unity Input Field. The logic has been split over multiple (platform specific) classes to improve readability. For Mobile platforms (Android, iOS & UWP) a whole new implementation has been written, because these were the platforms with the most annoying bugs. Also new bindings for the native keyboards on Android, iOS & UWP have been added to control more keyboard settings.

Supported platforms: PC, Mac, Android, iOS & UWP (Smartphone, Tablet & PC)

Features:

  • Default features on the original Unity InputField
  • Process edited text on deselect (using PostProcessingFilters)
  • Next Input Field option to control which InputField should be selected when done editing. (Tab key
    on Standalone platforms and Done/Next key on Mobile platforms).
  • Mobile only: Show ActionBar with cut, copy, paste and select all options
  • Mobile only: Selection Cursors (Draws selection sprites for start and end of text selection to control
    the selected text more easily in large text blocks)
  • Gestures for Mobile added: Single Tap: show ActionBar (if enabled)
    Double Tap: Select word
    Hold: Select word + show ActionBar (if enabled)
  • Event for keyboard height changes in the new NativeTouchScreenKeyboard binding.
  • Added a KeyboardScroller component to scroll content when TouchScreenKeyboard appears/hides.
  • Support for TextMeshPro Text Renderers
  • Multiple InputField Modes (indicates how to handle text bounds changes): SCROLL_TEXT, HORIZONTAL_RESIZE_FIT_TEXT and VERTICAL_RESIZE_FIT_TEXT

Feel free to contact me for feature requests and reporting bugs.
Please check the Trello board of the plugin before reporting bugs/asking for features:
Trello board

Changelog:
Pastebin link

1 Like

Hello and first of all thank you for this amazing Plugin! So far I am really happy with it, but there is something that I’d like to know. Currently the OnEndEdit function gets called when the inputfield is deselected so also when I dont press enter/done. Id only like it to get called when I submit and not when I just deselect it. Is this possible? and if so could you please help me to achieve this?

It should be possible as both events are handled separately internally in the plugin. OnDeselect event gets called from Unity side and OnKeyboardDone event gets called from Native (Android/iOS) side.
I’ll try to add a parameter to the OnEndEdit UnityEvent. Probably something named like “endEditReason”.

1 Like

This patch should do the job :wink:

Example:

public void OnInputEnd(string result, EndEditReason reason)
{
         if(reason == EndEditReason.KEYBOARD_DONE || reason == EndEditReason.KEYBOARD_NEXT)
         {

         }
}

Please report back if working properly, so I can add it in the main version

3172002–241650–Advanced Input Field 1.02b1_patch.unitypackage (143 KB)

1 Like

this works like a charm! exactly what I needed. this will be a easy 5 star review

1 Like

Version 1.0.2 Released:

  • Changed event callback signature for OnEndEdit(String) to OnEndEdit(String, EndEditReason)
    EndEditReason is a enum that specifies the reason for ending edit mode(Deselect, Keyboard Cancel, Keyboard Done, Keyboard Next)
  • Bugfix Android: Back key dismisses keyboard properly now

Hi,

I would need a UWP solution :slight_smile: Are there any plans to extend AdvancedInputField in this direction?

There weren’t any plans yet to support UWP, but I’m willing to look into it. Haven’t worked with UWP in Unity before.
What are your target devices, because UWP covers multiple types of devices? Phone, Tablet, PC?

My target devices are Tablet and PC.

That should be manageable. Other device types like Xbox and HoloLens would be more difficult.
I have a Surface Pro Tablet/PC, so I can use that for testing. For completion sake I would also need to test on a Phone. I’ll see if I can get a test phone somewhere.

I’ll try to experiment a bit with UWP when I have time this weekend to see how easily I can make a native TouchScreenKeyboard binding for that platform.

Great news! :slight_smile: Thank you very much for your efforts!

Just a small update: UWP binding is mostly working. Still need to fix some platform specific issues like handling change between tablet mode and pc mode. I’ll probably submit a new package to the Asset Store next week.

These are really good news! Thank you very much! :slight_smile:

Hello,

We tried using your solution for input field and it works ok only for Single Line (Line Type). If we select “Multi Line Newline” it does not work (Android):

  • When you move to a next line and start typing the upper line will just disappear
  • It’s not possible to scroll (it feels that the upper line is deleted)
  • The “caret” position has around -28.0f offset on Y (is just upper than normal and it looks strange)
  • If you keep pressing back to delete characters you will hit an “Index out of range” and eventually a “Null ref” that will cause a crash (at least on Android).

Are you planning to support multi line any time soon?

Thank you!

This will probably take some time. I’ll put it on my TODO list for this plugin, so I won’t forget to look into it.

Version 1.1.0 has just been released.
It includes UWP support and fixes some other issues.

That’s really great! I’ll try this on weekend. Thank you very much for releasing UWP support that quickly.:slight_smile:

I set character limit 0 and single line , when the text I entered is out of view scope, the text displayed is a problem. The text content does not move to the left.

That looks like it will be annoying to the end user. I’ll try to fix this ASAP and I’ll probably post a patch here in this thread. Asset Store approval usually takes longer.

Just to give an update: I cannot compile because I’ve updated to VS 2017.3 and am waiting for a patch for unity.:frowning: