Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

TextMesh Pro TextMesh Pro InputField Incorrect Editing Behavior on Emojis

Discussion in 'Unity UI & TextMesh Pro' started by foundway, Nov 8, 2018 at 1:09 AM.

  1. foundway

    foundway

    Joined:
    May 30, 2013
    Posts:
    14
    Hi,

    I am trying default emoji support with unicode in the out-of-box package (with EmojiOne). What I found is that displaying is perfect, but while I use the provided 16 emojis in TMP_InputField. Something unwanted happened when I try to Backspace or Select and Edit.

    To reproduce:
    1. Import TextMesh Pro
    2. Create a new scene
    3. Create a TextMesh Pro - InputField (TMP_InputField)
    4. Type one of the 16 provided emoji (for test purpose, just copy and paste this character: )
    5. The emoji should display correctly at this point
      01.PNG
    6. While Caret is at the end, hit Backspace and it becomes:
      02.PNG
      And we got unstopping errors:
      Assertion failed: TLS Allocator ALLOC_TEMP_THREAD, underlying allocator ALLOC_TEMP_THREAD has unfreed allocations, size 71680
    7. The same thing happen if you hit Delete while caret is at the beginning of the input field.
    Seems like Emoji 6.0 uses two characters in Unity's text field but keyboard operation works only one character at a time. So far I haven't able to find any work around. Anyone runs into the same issue?
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,773
    This is a known issue and something I need to address.

    Most Emojis are mapped in the UTF32 range and require the use of surrogate pairs. So when you delete / use backspace, you end up deleting half of the surrogate pair which is an invalid character and leads to this issue.
     
  3. faleoc

    faleoc

    Joined:
    Aug 13, 2018
    Posts:
    1
    Thanks for your prompt response!

    I plan to try two possible workarounds:
    (1) Process TMP_InputField.text at OnValueChanged to remove the left over invalid character. But problem with this method is that the Assertion failure will probably still happen.
    (2) Use <sprite=xxx> fallback in text and process it at OnValueChanged with REGEX to remove unpaired "<" or ">". This method is probably more reliable than former one.

    Any other ideas? I'll post how the workaround works here when I get to it.