Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Advanced Input Field

Discussion in 'Assets and Asset Store' started by fennecx_development, Jul 29, 2017.

  1. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    Ok I have found a multiline sample that does the job.
     
  2. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    @jpienbro Where can I find docs or code samples on events?
     
  3. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    @jpienbro I am using a custom script to prevent TMPro input field from stealing focus and stopping my scroll rect from dragging, thus allowing the user to be able to drag smoothly with UI dense with input fields. Does AIF have an alternative? If not, will this work? (for the AIF part):

    Code (CSharp):
    1. using TMPro;
    2. using UnityEngine;
    3. using UnityEngine.EventSystems;
    4. using UnityEngine.UI;
    5. using AdvancedInputFieldPlugin;
    6. using System;
    7.  
    8.     [RequireComponent(typeof(TMP_InputField))]
    9.     public class InputFieldScrollFixer : MonoBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler, IScrollHandler, IPointerUpHandler
    10.     {
    11.         private ScrollRect _scrollRect;
    12.         private TMP_InputField _input;
    13.         private AdvancedInputField _inputAIF;
    14.         private bool _isDragging;
    15.         private bool _preventScrollRectDrag;
    16.         public bool mUsesAIF = false;
    17.         private void Start()
    18.         {
    19.             _scrollRect = GetComponentInParent<ScrollRect>();
    20.             _input = GetComponent<TMP_InputField>();
    21.             if (!mUsesAIF)
    22.             {
    23.                 _input.DeactivateInputField();
    24.                 _input.onDeselect.AddListener(_ => _preventScrollRectDrag = false);
    25.             }
    26.             else
    27.             {
    28.                 _inputAIF = GetComponent<AdvancedInputField>();
    29.                 _inputAIF.enabled = false;
    30.                 _inputAIF.OnDeselect(OnDes);
    31.             }
    32.  
    33.         }
    34.         BaseEventData OnDes(BaseEventData data)
    35.         {
    36.             _preventScrollRectDrag = false;
    37.             return data;
    38.         }
    39.  
    40.         public void OnBeginDrag(PointerEventData data)
    41.         {
    42.             if (_preventScrollRectDrag)
    43.                 return;
    44.  
    45.             _scrollRect.OnBeginDrag(data);
    46.             _isDragging = true;
    47.  
    48.             _input.DeactivateInputField();
    49.         }
    50.  
    51.         public void OnDrag(PointerEventData data)
    52.         {
    53.             _scrollRect.OnDrag(data);
    54.         }
    55.  
    56.         public void OnEndDrag(PointerEventData data)
    57.         {
    58.             _scrollRect.OnEndDrag(data);
    59.             _isDragging = false;
    60.         }
    61.  
    62.         public void OnScroll(PointerEventData data)
    63.         {
    64.             _scrollRect.OnScroll(data);
    65.         }
    66.  
    67.         public void OnPointerUp(PointerEventData data)
    68.         {
    69.             if (!_isDragging && !data.dragging)
    70.             {
    71.                 _input.ActivateInputField();
    72.                 _preventScrollRectDrag = true;
    73.             }
    74.         }
    75.     }
    76.  
    77.  
     
  4. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    @jpienbro I receive this error on build (Play Services Resolution failed):
    Code (CSharp):
    1. Failed to fetch the following dependencies:
    2. com.google.android.gms:play-services-analytics:17.1.0@aar
    3. com.google.android.gms:play-services-auth:17.1.0@aar
    4. com.google.android.gms:play-services-analytics-impl:17.1.0@aar
    5. com.google.android.gms:play-services-stats:17.1.0@aar
    6. com.google.android.gms:play-services-tagmanager-v4-impl:17.1.0@aar
    7. com.google.android.gms:play-services-ads-identifier:17.1.0@aar
    8.  
    9.  
    10. UnityEngine.Debug:LogError(Object)
    11. GooglePlayServices.PlayServicesResolver:LogDelegate(String, LogLevel)
    12. Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean)
    13. GooglePlayServices.ResolverVer1_1:LogMissingDependenciesError(List`1)
    14. GooglePlayServices.<DoResolutionUnsafe>c__AnonStorey18:<>m__28(List`1)
    15. GooglePlayServices.<GradleResolution>c__AnonStorey14:<>m__20(Result)
    16. GooglePlayServices.<GradleResolution>c__AnonStorey15:<>m__2B()
    17. GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
    18. UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
    19.  
     
  5. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    It should be the default behaviour when creating an AdvancedInputField instance. It's controlled by the property called "SelectionMode". It should be "SELECT_ON_RELEASE" to get the behaviour you want. Also, see the Form sample scene. In that scene you can press an inputfield without selecting it and still drag the ScrollRect. The inputfield will be focused if you actually tap the inputfield without dragging too much.
     
  6. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    Most events should be straight forward. The only ones that might be a bit different are the OnBeginEdit and OnEndEdit events with include a reason parameter to specify why the inputfield started edit mode or stopped edit mode (for example: KEYBOARD_DONE if the user pressed the done key on the keyboard and KEYBOARD_CANCEL if the user choose to hide the keyboard).
     
  7. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    Might be a conflict with the versions of those libraries referenced in the plugin and the ones references by your project. The dependencies file for Android used by the plugin is located in the Assets/Plugins/Advanced Input Field/Editor/Dependencies.xml.
    You might need to modify the version of the libraries used in that file.
     
  8. gouasmimedlotfi

    gouasmimedlotfi

    Joined:
    Oct 13, 2019
    Posts:
    9
    Hello there, good job with the plugin, i really love it... when it works

    I'm getting some weird bugs :
    i modified the plugin a little so that it uses RTLTextmeshpro which is a script that allows me to use RTL letters, replacing TextMeshProGUI as text component (RTLTextmeshpro : TextMeshProGui) and it works...

    but the weird thing is, when i add an input field in editor and test it out, it works properly, but sometimes when i test it on my android device, the keyboard doesn't show up, and back in editor, it doesn't either; why ? because somehow, the AdvancedInputField component gets disabled at start, when i enable it on play mode it works properly

    those are the errors i'm getting on console :

    IndexOutOfRangeException: Index was outside the bounds of the array.
    UnityEngine.UI.Selectable.OnDisable () (plenty of that)

    NullReferenceException: Object reference not set to an instance of an object
    AdvancedInputFieldPlugin.TMProTextRenderer.RefreshCharacterData () (at Assets/Plugins/Advanced Input Field/Scripts/InputField/TMProTextRenderer.cs:264) (lineCount = textInfo.lineCount;)

    IndexOutOfRangeException: Index was outside the bounds of the array.
    (wrapper stelemref) System.Object.virt_stelemref_class(intptr,object)
    UnityEngine.UI.Selectable.OnDisable () (at D:/Unity Editors/2019.4.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Selectable.cs:526)
    AdvancedInputFieldPlugin.AdvancedInputField.OnDisable () (at Assets/Plugins/Advanced Input Field/Scripts/InputField/AdvancedInputField.cs:1349)


    when i remove the inputField, and add a new one, it does work once again in play mode, but back on android, one or multiple inputfields get their advancedinputfield component disabled

    would appreciate the help, is there some sort of limit on how many inputs we can add lol ?

    Edit : I can fix it by waiting for 0.2 second and enabling the problematic AdvancedInputField, but that's still weird
     
    Last edited: Aug 19, 2020
  9. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    Thanks, will check that out
     
  10. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    @jpienbro I already had play services, changing your dependencies to my version did not help, commenting out only play services did not help either. Commenting out all made it build. What do I need play-services-auth-api-phone for? Contacts access?
     
  11. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    @jpienbro the caret if off until some text is present. Without any text it is misplaced above and badly size. After some input, it takes proper size and position. How to fix that?
     
    gouasmimedlotfi likes this.
  12. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    As right to left editing is not officially supported by the plugin yet, it's not strange that weird things will happen if you modify the default TextMeshPro renderer to get this behaviour.
    The plugin internally recalculates the CharacterInfo index of the rendered characters, because by default TextMeshPro has some problems with giving the correct character indexes. I suspect that your right to left editing script is also changing those CharacterInfos and this is causing those IndexOutOfRangeExceptions.

    If you can make a small repro project I can take a look, but no guarantees that I'll be able to find a quick fix.
     
    gouasmimedlotfi likes this.
  13. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    It's only needed if you want to use one time code autofill (SMS), so if you don't need that you can ignore that dependency.
     
  14. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    Do you also have this issue in the sample scenes?
    Did you maybe change the RectTransform of any of the child objects of the AdvancedInputField instance? You can modify the TextArea object to add some padding, but all child object of that TextArea object should be left untouched.
     
  15. gouasmimedlotfi

    gouasmimedlotfi

    Joined:
    Oct 13, 2019
    Posts:
    9
    I managed to make it work with the RTL fixer script (i'm using this https://forum.unity.com/threads/rtl...ian-and-arabic-support-to-textmeshpro.535758/ ) because i need to have arabic in my app.

    i deleted the TM Pro Text renderer script from all 3 Text Components , replaced original TextMeshProUgui components with it's new subclass called RTLTextmeshpro, then added back the script

    i'm also using layout managers, and sometimes, when using disabled then enabled aif game objects, when i empty an input field, the placeholder is not showing properly becuase of the content's rect transform being too narrow, or simply misplaced, so what i did is i added this in the UpdateSize method (on AdvancedInputField script) :

    Code (CSharp):
    1. internal void UpdateSize(TextRenderer textRenderer)
    2.         {
    3.             Vector2 size = Size;
    4.             Vector2 preferredSize = textRenderer.PreferredSize;
    5.             if (string.IsNullOrEmpty(Text))
    6.             {
    7.                 TextContentTransform.anchoredPosition = Vector3.zero;
    8.                 preferredSize = new Vector2(preferredSize.x+30, preferredSize.y);
    9.             }
    10.             TextContentTransform.sizeDelta = preferredSize;
    11. .
    12. .
    13. .
    14. }
    15.  
    i still get some errors (specially multiples
    IndexOutOfRangeException: Index was outside the bounds of the array.
    (wrapper stelemref) System.Object.virt_stelemref_class(intptr,object)
    UnityEngine.UI.Selectable.OnDisable ()
    )

    but everything seems to be working fine

    Edit : there is something else to note there, arabic characters do not seem to show properly unless you use a multi line input field.
     
    Last edited: Aug 29, 2020
  16. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    41
    Hi,
    I am new to building for UWP, but when I try to Create App Package
    it shows me this error:

    Error Code: LNK2019

    unresolved external symbol _GetPageContent@8 referenced in function _UWPKeyboard_GetPageContent_m258F82FC7F1A3CB6C4A2CE9A33FAE02FD596F98E

    Il2CppOutputProject

    \Il2CppOutputProject\2486E08A76531ED27DC1F7C6D6AA9EC8.obj
     
  17. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    41

    Hi @gouasmimedlotfi, I am using LiveProcessor to have Arabic working with me (not the best thing, but it is doing the job)
    The trick part is getting the caret in the right position
    here is the code

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Text;
    4. using AdvancedInputFieldPlugin;
    5. using UnityEngine;
    6.  
    7. public class LiveProcessor_Arabic : LiveProcessingFilter
    8. {
    9.     /// <summary>The StringBuilder</summary>
    10.     private StringBuilder stringBuilder;
    11.  
    12.     /// <summary>The StringBuilder</summary>
    13.     public StringBuilder StringBuilder
    14.     {
    15.         get
    16.         {
    17.             if (stringBuilder == null)
    18.             {
    19.                 stringBuilder = new StringBuilder();
    20.             }
    21.  
    22.             return stringBuilder;
    23.         }
    24.     }
    25.  
    26.     public override string ProcessText(string text, int caretPosition)
    27.     {
    28.         StringBuilder.Length = 0; //Clears the contents of the StringBuilder
    29.         return Arabic.BidirectionalSupport.Fix(text);//StringBuilder.ToString();
    30.     }
    31.  
    32.     public override int DetermineProcessedCaret(string text, int caretPosition, string processedText)
    33.     {
    34.         return caretPosition;
    35.     }
    36.  
    37.     public override int DetermineCaret(string text, string processedText, int processedCaretPosition)
    38.     {
    39.         return processedCaretPosition;
    40.     }
    41. }
    42.  
     
    gouasmimedlotfi likes this.
  18. gouasmimedlotfi

    gouasmimedlotfi

    Joined:
    Oct 13, 2019
    Posts:
    9
    the thing is, i'm not using arabic exclusively, i'm mixing french/english and arabic, so does this still work when doing that, does it only fix text if it detects arabic characters ?
     
  19. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    41
    it should work fine for other languages, but better to test

    Also there is a wrapper fro Konash Arabic Fix plugin called "BidirectionalSupport" that would make sure text is working fine even if it contains Latin & Arabic letters in the same text.
    Please check:
    https://github.com/Konash/arabic-support-unity/issues/12
     
    gouasmimedlotfi likes this.
  20. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    Are you trying to build a uwp project from the Unity Editor or is this a step further already and building specifically for an app store release? I'm not really familiar with UWP publishing for an app store.

    Are you using XAML or D3D as the build type when building it from within the Unity Editor? D3D seems to give issues. I suspect it is stripping some UWP UI classes then. When possible try to use XAML as the build type.

    The method in the error you posted mentions is in a separate cpp file (Assets/Plugins/Advanced Input Field/WSA/NativeUtil.cpp), so maybe that gets stripped out for some reason in your build. That method was a way to get the native UI Page (since the transition to IL2CPP for UWP builds) and posted by someone at Unity.
     
  21. timbokoppers

    timbokoppers

    Joined:
    Nov 14, 2016
    Posts:
    69
    Hi, I'm getting this error on an Android build. Build with 2019.4.f8, IL2CPP, .NET 4x and gradle. It's an AAB build.

    AndroidJavaException: java.lang.ClassNotFoundException: com.jeroenvanpienbroek.nativekeyboard.NativeKeyboard


    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.jeroenvanpienbroek.nativekeyboard.NativeKeyboard" on path: DexPathList[[zip file "/data/app/com.objectnull.ultimate.intensivist-sbEIeMArSplVnAYAIQuQyg==/base.apk", zip file "/data/app/com.objectnull.ultimate.intensivist-sbEIeMArSplVnAYAIQuQyg==/split_config.arm64_v8a.apk"],nativeLibraryDirectories=[/data/a
     
  22. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    41
    Hi,

    I built a UWP project using Unity ( yup it was D3D, will try XAML ) and yes it was a build for the App Store

    I want to build a desktop/Windows app, is this method related to Windows phone or is required also for Windows desktop?

    will try XAML, and keep you updated,

    Thanks
     
  23. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    Just tested it in a clean Unity project with this plugin installed using Unity 2019.4.9 and your build settings and it seems to work normally. Maybe the Android library of the plugin gets stripped out in your build, then it would give a ClassNotFoundException. That library file (NativeKeyboard.aar) should be in Assets/Plugins/Android and should get included in the build.
     
    timbokoppers likes this.
  24. timbokoppers

    timbokoppers

    Joined:
    Nov 14, 2016
    Posts:
    69
    Yes somehow the error is gone indeed. I don't know exactly what I did. Thanks !
     
  25. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    41
    Hi @jpienbro ,

    Tried XAML, but it reported the same error.

    is that function "GetPageContent" essential ? can I just delete it & it's calls?
    Please let me know your thoughts

    Thanks
     
  26. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    The function is not really needed anymore, since it was used to determine the type of device that was being used and Microsoft stopped their development on Windows Phone anyways now.
    You can also change the "KeyboardBehaviour" in the Global Settings (TopBar: AdvancedInputField => Global Settings) to "ALWAYS_USE_HARDWAREKEYBOARD". Then it should not even call that function anymore, but the compiler might still check if though.
     
  27. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    41
    Cool, Thanks already removed it & the calls to it, and it is working fine now

    Appreciate your help.
     
  28. liyangw107

    liyangw107

    Joined:
    Aug 27, 2019
    Posts:
    12
    Your assets is great. but i have some issue.
    I have multiple inputfields on my mobile screen.
    when i tap inputfield, keyboard is overpass the inputfields.
    so while typing, i cannot see inputfields.
    Please help me if there is a solution.
    Thank you.
     
  29. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    @jpienbro I am using vertical scroll rect for my UI and I can't drag the content up or down if native keyboard is open. How to change that?
     
  30. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    I am referring iOS here.
     
  31. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    You can use the KeyboardScroller component to handle it when using a ScrollRect. See the ReadMe and the sample scene Form as an example. Also, you could handle moving the inputfield yourself when the keyboard appears by registering to the OnKeyboardHeightChanged event. (NativeKeyboardManager.AddOnKeyboardHeightChangedListener()). See the sample scene Modes (bottom inputfield) as an example for moving the inputfield on top of the keyboard when the keyboard appears.
     
  32. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    If you mean the issue that when you tap something else like the background of the scrollrect that the inputfield will be deselected, that's unfortunately a limitation of the Unity UI EventSystem. You can counteract this behaviour a bit by setting the .ShouldBlockDeselect property to true on the focused inputfield. Then it will automatically reselect that inputfield whenever the Unity UI EventSystem tries to deselect it (and keep the keyboard onscreen). You would need to set that flag back to false when you are done editing that inputfield or want to focus another inputfield though.
     
  33. ttravi-soulside

    ttravi-soulside

    Joined:
    Sep 20, 2020
    Posts:
    3
    Good evening.

    Nothing works, when I click on any input field on any of the samples it returns a lot of errors on console:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. AdvancedInputFieldPlugin.AdvancedInputField.OnPointerDown (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/_ThirdParty/Runtime/Advanced Input Field/Scripts/InputField/AdvancedInputField.cs:2746)
    3. AdvancedInputFieldPlugin.ScrollArea.OnPointerDown (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/_ThirdParty/Runtime/Advanced Input Field/Scripts/InputField/ScrollArea.cs:1105)
    4. UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerDownHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at D:/Unity/2019.4.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:36)
    5. UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at D:/Unity/2019.4.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
    6. UnityEngine.EventSystems.EventSystem:Update() (at D:/Unity/2019.4.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
    7.  
     
  34. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    Hmm, strange...I couldn't reproduce this error in the Unity version you were using (2019.4.1):
    - Created a clean Unity project in Unity 2019.4.1
    - Installed latest version of the plugin from the AssetStore
    - Opened the Form sample scene
    - Clicked on a inputfield and I got no errors and could type characters as expected

    Maybe the package was not completely imported or another plugin is conflicting with it. Could you try reimporting the package and/or check this in a clean Unity project?
     
    ttravi-soulside likes this.
  35. RJproz

    RJproz

    Joined:
    May 19, 2013
    Posts:
    52
    Hi jpienbro,
    The asset is fantastic. But I am facing two issues.
    1) I marked the inputfield as readonly, but the keyboard pops up when the application comes to foreground. It happens both in Editor and Android build.
    https://imgur.com/a/ppefomZ

    2) Actionbar position doesn't take the root position into account. I have a world canvas positioned at (-100,0,0) but there action bar stays far away. This issue doesn't occur if I move the world canvas to Vector3.Zero.

    Edit: I am using Unity 2019.4.9f1
     
    Last edited: Sep 24, 2020
  36. Soulside

    Soulside

    Joined:
    Nov 1, 2018
    Posts:
    30
    Hello!
    Thanks for quick response. The issue here was because the example scenes that are coming with the plugin does not support domain and scene reloading experimental feature.
     
  37. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    Couldn't really reproduce the issues:
    1. In the Form sample scene I tried enabling the ReadOnly property on the Username inputfield and on run time no keyboard appears and input is blocked.
    2. In the Form sample scene tried changing the canvas to world canvas and adding an offset so the canvas is moved a bit to the left. ActionBar still seems to be visible, at least within the camera view. Maybe your scene setup is different, perhaps using multiple cameras?

    Could you make a small repro project for the issues? That would make it easier to fix.
     
  38. shuskry

    shuskry

    Joined:
    Oct 10, 2015
    Posts:
    462
    Hello :)

    -I found some little bug .
    On Ios, the blue cursor stay oustide the box when I release it outside the inpputfield.

    -For the Emoji, only few of them work , for the other, I have little square instead of emoji, there is a way to add the other by myself?

    -Is it possible to move the Carret with the Space bar like in the native keyboard ?

    - If I’m using Scroll text option , the scroll movement is inverse , and it’s select the text in the same time

    Thanks for your work, the asset seems to resolve lot of inputfield problem :D !!
     
    Last edited: Sep 28, 2020
  39. shuskry

    shuskry

    Joined:
    Oct 10, 2015
    Posts:
    462
    Hi again :)

    I have a little problem with the Input field.

    If I write something, then delete all . if the first next character is "/n (return line touch on keyboard)" I have a error message :

    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <fb001e01371b4adca20013e0ac763896>:0)
    System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <fb001e01371b4adca20013e0ac763896>:0)
    System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <fb001e01371b4adca20013e0ac763896>:0)
    AdvancedInputFieldPlugin.TMProTextRenderer.RefreshLineData () (at Assets/Plugins/Advanced Input Field/Scripts/InputField/TMProTextRenderer.cs:540)
    AdvancedInputFieldPlugin.TMProTextRenderer.RefreshData () (at Assets/Plugins/Advanced Input Field/Scripts/InputField/TMProTextRenderer.cs:255)
    AdvancedInputFieldPlugin.TMProTextRenderer.UpdateImmediately (System.Boolean generateOutOfBounds) (at Assets/Plugins/Advanced Input Field/Scripts/InputField/TMProTextRenderer.cs:232)
    AdvancedInputFieldPlugin.TMProTextRenderer.set_Text (System.String value) (at Assets/Plugins/Advanced Input Field/Scripts/InputField/TMProTextRenderer.cs:79)
    AdvancedInputFieldPlugin.MobileTextInputHandler.ProcessTextEditUpdate (AdvancedInputFieldPlugin.NativeKeyboard+Event keyboardEvent) (at Assets/Plugins/Advanced Input Field/Scripts/InputField/MobileTextInputHandler.cs:289)
    AdvancedInputFieldPlugin.MobileTextInputHandler.Process () (at Assets/Plugins/Advanced Input Field/Scripts/InputField/MobileTextInputHandler.cs:101)
    AdvancedInputFieldPlugin.AdvancedInputField.OnUpdateSelected (UnityEngine.EventSystems.BaseEventData eventData) (at Assets/Plugins/Advanced Input Field/Scripts/InputField/AdvancedInputField.cs:2822)
    UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IUpdateSelectedHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at D:/Unity Test/2019.4.10f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:99)
    UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at D:/Unity Test/2019.4.10f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
    UnityEngine.EventSystems.EventSystem:Update() (at D:/Unity Test/2019.4.10f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)


    After that I can't write somethings on the keyboard on IOS , I need to deselect the Inpufield then reselect It to write again...
     
    Last edited: Oct 2, 2020
  40. RJproz

    RJproz

    Joined:
    May 19, 2013
    Posts:
    52
    Yeah It only happens with my setup. Also Yes, I have multiple cameras and as the canvas is loaded via assetbundle, the world space camera is assigned afterwards. But I also tried put the canvas in the scene with the camera before running but still both issue persists. I will try to reproduce it in some minimum setup and will sent it to you.
     
  41. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    1. Couldn't reproduce it, Tested it using the Multiline sample scene on a iPhone and dragging one of the blue cursors outside of the inputfield. Did you do anything specific to get the cursor stuck?

    2. Emoji support currently relies on the TextMeshPro implementation which currently has limitations, such as using the more complex emoji character sequences. Currently on 1 and 2 character emojis work. I'm working on a way to support the full emoji range (and other more complex features) for next major release (2.0.0). Don't have an eta for that version yet though.

    3. You can change the CaretPosition on runtime using code by modifying the .CaretPosition property of an AdvancedInputField instance.

    4. Not sure what you mean by the scroll direction if inversed, but the default drag mode is to update the text selection.
    If you want to drag without changing the text selection you might want to change the "DragMode" property of an AdvancedInputField to MOVE_TEXT. An example of an AdvancedInputField configured this way can be found in the sample scene "Multiline" (Bottom inputfield)
     
  42. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    Hmm, I've had problems with TextMeshPro and newline characters before, but can't seem to reproduce the error. Maybe I did something differently:
    Tested on iPhone XS:
    - Selected a multiline inputfield with TextMeshPro renderers
    - Selected all text and pressed the clear/delete key on the native keyboard
    - Added a newline using the return key on the native keyboard
    - Typed something
    - Selected the last part of the text that I just typed
    - Pressed the clear/delete key on the native keyboard (Only newline character remains)
    - No error and could still type
     
  43. ttravi-soulside

    ttravi-soulside

    Joined:
    Sep 20, 2020
    Posts:
    3
    I'm sorry, I managed to solve it but forgot to return here with my feedback.

    The problem was the "Enter Play Mode Options" enabled. After disabling it the plugin works.

    Best Regards
     
  44. jiraphatK

    jiraphatK

    Joined:
    Sep 29, 2018
    Posts:
    251
    Hi. I have problem with caret position.
    I use Advanced InputField with TMP 2.1.1 and Latest Advanced InputField package


    EDIT
    fix by this post
     
    Last edited: Oct 7, 2020
  45. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    41
    error from some windows devices

    NullReferenceException: Object reference not set to an instance of an object.


    NativeKeyboardUWP.NativeKeyboard.<EnableUpdates>b__57_0 () (at <00000000000000000000000000000000>:0) UnityEngine.Canvas+WillRenderCanvases.Invoke () (at <00000000000000000000000000000000>:0) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <00000000000000000000000000000000>:0) System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <00000000000000000000000000000000>:0) BetterJSON.StringValue..cctor () (at <00000000000000000000000000000000>:0) System.Runtime.Serialization.DeserializationEventHandler.Invoke (System.Object sender) (at <00000000000000000000000000000000>:0) System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <00000000000000000000000000000000>:0) System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () (at <00000000000000000000000000000000>:0) AdvancedInputFieldPlugin.OnMobileCursorMoveFinished.Invoke () (at <00000000000000000000000000000000>:0) System.Threading.SendOrPostCallback.Invoke (System.Object state) (at <00000000000000000000000000000000>:0) UnityEngine.WSA.WindowSizeChanged.BeginInvoke (System.Int32 width, System.Int32 height, System.AsyncCallback callback, System.Object object) (at <00000000000000000000000000000000>:0) UnityEngine.UnitySynchronizationContext.Exec () (at <00000000000000000000000000000000>:0) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <00000000000000000000000000000000>:0) System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) (at <00000000000000000000000000000000>:0) System.Threading.SendOrPostCallback.Invoke (System.Object state) (at <00000000000000000000000000000000>:0) UnityEngine.WSA.WindowSizeChanged.BeginInvoke (System.Int32 width, System.Int32 height, System.AsyncCallback callback, System.Object object) (at <00000000000000000000000000000000>:0) UnityEngine.UnitySynchronizationContext.Exec () (at <00000000000000000000000000000000>:0) UnityEngine.UnitySynchronizationContext:Exec()



    another one from same device:


    NativeKeyboardUWP.NativeKeyboard.<EnableHardwareKeyboardUpdates>b__59_0 () (at <00000000000000000000000000000000>:0) UnityEngine.Canvas+WillRenderCanvases.Invoke () (at <00000000000000000000000000000000>:0) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <00000000000000000000000000000000>:0) System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <00000000000000000000000000000000>:0) BetterJSON.StringValue..cctor () (at <00000000000000000000000000000000>:0) System.Runtime.Serialization.DeserializationEventHandler.Invoke (System.Object sender) (at <00000000000000000000000000000000>:0) System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <00000000000000000000000000000000>:0) System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () (at <00000000000000000000000000000000>:0) AdvancedInputFieldPlugin.OnMobileCursorMoveFinished.Invoke () (at <00000000000000000000000000000000>:0) System.Threading.SendOrPostCallback.Invoke (System.Object state) (at <00000000000000000000000000000000>:0) UnityEngine.WSA.WindowSizeChanged.BeginInvoke (System.Int32 width, System.Int32 height, System.AsyncCallback callback, System.Object object) (at <00000000000000000000000000000000>:0) UnityEngine.UnitySynchronizationContext.Exec () (at <00000000000000000000000000000000>:0) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <00000000000000000000000000000000>:0) System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) (at <00000000000000000000000000000000>:0) System.Threading.SendOrPostCallback.Invoke (System.Object state) (at <00000000000000000000000000000000>:0) UnityEngine.WSA.WindowSizeChanged.BeginInvoke (System.Int32 width, System.Int32 height, System.AsyncCallback callback, System.Object object) (at <00000000000000000000000000000000>:0) UnityEngine.UnitySynchronizationContext.Exec () (at <00000000000000000000000000000000>:0) UnityEngine.UnitySynchronizationContext:Exec()
     
    Last edited: Oct 6, 2020
  46. shuskry

    shuskry

    Joined:
    Oct 10, 2015
    Posts:
    462
    I have this error too with the example scene in unity editor for textmeshpro ( orange chat).

    -Play the scene
    -click on the chat
    -press the touch "enter"
    -press the touch "erase"
    -press touch " enter " again

    and then the error message appear

    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <fb001e01371b4adca20013e0ac763896>:0)
    System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <fb001e01371b4adca20013e0ac763896>:0)
    System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <fb001e01371b4adca20013e0ac763896>:0)
    AdvancedInputFieldPlugin.TMProTextRenderer.RefreshLineData () (at Assets/Plugins/Advanced Input Field/Scripts/InputField/TMProTextRenderer.cs:542)
    AdvancedInputFieldPlugin.TMProTextRenderer.RefreshData () (at Assets/Plugins/Advanced Input Field/Scripts/InputField/TMProTextRenderer.cs:255)
    AdvancedInputFieldPlugin.TMProTextRenderer.UpdateImmediately (System.Boolean generateOutOfBounds) (at Assets/Plugins/Advanced Input Field/Scripts/InputField/TMProTextRenderer.cs:232)
    AdvancedInputFieldPlugin.TMProTextRenderer.set_Text (System.String value) (at Assets/Plugins/Advanced Input Field/Scripts/InputField/TMProTextRenderer.cs:79)
    AdvancedInputFieldPlugin.MobileTextInputHandler.ProcessTextEditUpdate (AdvancedInputFieldPlugin.NativeKeyboard+Event keyboardEvent) (at Assets/Plugins/Advanced Input Field/Scripts/InputField/MobileTextInputHandler.cs:289)
    AdvancedInputFieldPlugin.MobileTextInputHandler.Process () (at Assets/Plugins/Advanced Input Field/Scripts/InputField/MobileTextInputHandler.cs:101)
    AdvancedInputFieldPlugin.AdvancedInputField.OnUpdateSelected (UnityEngine.EventSystems.BaseEventData eventData) (at Assets/Plugins/Advanced Input Field/Scripts/InputField/AdvancedInputField.cs:2822)
    UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IUpdateSelectedHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at D:/Unity Test/2019.4.11f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:99)
    UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at D:/Unity Test/2019.4.11f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
    UnityEngine.EventSystems.EventSystem:Update() (at D:/Unity Test/2019.4.11f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
     
  47. fennecx_development

    fennecx_development

    Joined:
    Sep 24, 2014
    Posts:
    427
    Seems like it's a bug in TextMeshPro 2.1.0 (& 2.1.1) that it sometimes gives invalid character info when the only character is a newline. I've added a workaround to check for this scenario and correct the character info.

    See attachment for updated TMProTextRenderer.cs file.
     

    Attached Files:

  48. shuskry

    shuskry

    Joined:
    Oct 10, 2015
    Posts:
    462
    THANKS TO YOU !! That was my biggest problem for now ! I will put a review for your work ! thanks again !
     
  49. shuskry

    shuskry

    Joined:
    Oct 10, 2015
    Posts:
    462
    @jpienbro
    Hello again, I found a little bug , and I don't know if it's normal or not .

    I made a changeable mode input field.
    If the inputfield.text.linecount is > 3 , I change the mode "Vertical fit size " to " Scrolltext".
    Then , when I click on the send button, I change the Inputfield.text to null, and I reset the mode to "vertical Fit Size"

    The problem is , after the mode is change, I lose the focus on the inputField.
    The keyboard keep showing, I can type on it, but the inputfield text is not actualize ...
    I know that the text is working, but I need to deselect the inputfield and reselect it to make it appear.

    Here my code :
    Code (CSharp):
    1.  
    2.  
    3. public void SendNEwMessage()
    4.     {
    5.         if(inputField.Text == "")
    6.         {
    7.             return;
    8.         }
    9.  
    10.         Debug.Log("Send new message call:" + newmess);
    11.         inputField.Mode = InputFieldMode.VERTICAL_RESIZE_FIT_TEXT;
    12.         inputField.Text = "";
    13.     }
    14.  
    And here the video:


    I tried to add this after the last line but nothings change :
    Code (CSharp):
    1. inputField.Select();
    I don't use other line of code which can affect the Inputfield :/

    EDIT : the problem happen only when I click on Send( wich have Inputfield button script on it) and the inputfield mode is set to scroll text.
    If the Inputfield text.linecount < 3 , so Inputfield mode is not change to scrollText , all work perfectly ! So the problem is changing Inputfield mode during focus ?
     
    Last edited: Oct 17, 2020
  50. ttravi-soulside

    ttravi-soulside

    Joined:
    Sep 20, 2020
    Posts:
    3
    Good evening. I'm trying to make a field with the following rules:
    1 - Double space turns into an underscore
    2 - It is not allowed to write two special characters in a row. Eg: string__string, string..string.