Search Unity

TextMesh Pro InputField allows me to edit rich text when I use backspace

Discussion in 'UGUI & TextMesh Pro' started by Sylmerria, Mar 8, 2019.

  1. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    Hi,

    I have a input field which shows smiley all fine.
    When I use backspace even with option "Allow Rich Text Editing" set to off, I can edit rich text

    Before backspace :


    After backspace :



    It comes from bad setting or it's the normal behavior ?

    Thanks
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Sprites / Emoji's which can be referenced using both a tag like <sprite=0> and a unicode value (if one assigned to the sprite) are considered characters and as such excluded from the Edit rich text part.
     
  3. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    Ok thanks :)
     
  4. LYN1995

    LYN1995

    Joined:
    Apr 28, 2019
    Posts:
    11
    How to use that?
    I use it like "hello<sprite=1/emojis>",but it does not work!
    can you give me a simple example? thank u.
     
    Last edited: Apr 28, 2019
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You can either use the sprite tag like <sprite=0> where the 0 is the index of the sprite in the sprite asset. You can also reference the sprite using the other variants of the sprite tag like <sprite="Name of Sprite Asset" index=0>. See the following for additional variants.

    If the sprites are assigned a unicode value in the Sprite Asset, they can also be referenced that way.
     
    LYN1995 likes this.
  6. LYN1995

    LYN1995

    Joined:
    Apr 28, 2019
    Posts:
    11
    Do you have any technical engineers who can speak Chinese? I can't express myself clearly in English.:(
    I do not know how to use that "Sprites / Emoji's"
     
    Last edited: Apr 28, 2019
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Write your question in Chinese and hopefully Google Translate will do a good enough job for me to understand. If not, I'll reach out to some of the folks in Unity that are fluent in the Chinese language.

    and just to keep trying to help,

    Is the issue in typing / input of Emoji?

    Is the issue in creating sprite assets?

    or how to use the sprite tag?

    Create a video showing the issue you are having. Maybe that will give me a better sense of what your are having an issue with.

    P.S. Make sure you also test with the latest release of TMP which is version 1.4.1-preview.1 for Unity 2018.3 or 2.0.1-preview.1 for Unity 2019.1 as these release do include improved support for <sprite> tag in terms of the backspace deleting the whom tag as well as better handling of surrogate pairs which Emojis mapped in the UTF 32 range do use.
     
  8. LYN1995

    LYN1995

    Joined:
    Apr 28, 2019
    Posts:
    11
    我的问题和提问者的一样,但是我是新手,我不知道这个问题到底该怎么解决!在你的回答中提到了“Sprites / Emoji's”,这是一个标签吗?还是一个设置?

    My problem is the same as that of the questioner, but I am a novice. I don't know how to solve this problem. In your answer, you mentioned "Sprites / Emoji's". Is this a label? Or is it a setup?
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Neither. It is referencing the ability to display Sprites or Inline Graphics or Emojis where these terms all refer to the same thing.

    Create a text object as follows:

    upload_2019-4-28_0-23-23.png

    Then type the text as seen below

    upload_2019-4-28_0-26-11.png

    This will produce the following results.

    upload_2019-4-28_0-26-39.png

    The above Sprite / Emoji / Smiley face is the result of using the <sprite=0> tag. This smiley face is coming from the EmojiOne Sprite Asset assigned in the TMP Settings as a Default Sprite Asset.

    The ability to use the <sprite> tag also works in the TMP_InputField. When Allow Rich Text Editing is disabled, the sprite / emoji is treated like any other character and will be deleted by using Backspace. If Allow Rich Text Editing is enabled, using the backspace when the cursor is placed after the Emoji or Sprite (again these are the same thing), the rich text tag underneath will be revealed thus showing "<sprite=0" since the ">" has been deleted by the backspace.
     
    LYN1995 likes this.
  10. LYN1995

    LYN1995

    Joined:
    Apr 28, 2019
    Posts:
    11
    This answer solves my problem.thanks!
     
    Stephan_B likes this.