Search Unity

Using emoticons - scripting

Discussion in 'UGUI & TextMesh Pro' started by Saicopate, Nov 22, 2019.

  1. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    Hey! I noticed that with current TMPro you can display emoticons in line with text. All works great when you assign them in the editor. I do it by copying from getemoji.com page and pasting to TextMeshProUGUI text window.

    My question is how to use emoticons when assigning text (string) values by scripts? Do they have IDs so that we can use them in line with text?
     
  2. jonahyakuto

    jonahyakuto

    Joined:
    Mar 9, 2017
    Posts:
    11
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    It is important to understand that Emojis like any other character are mapped to some unicode value. Some are mapped in the UTF16 range and others in the UTF32.

    To access Unicode characters in C# strings, you can use the Unicode Escape Sequence \uFF00 which \u + 2 Hex pair for UTF16 and \UFF00FF00 or \U + 4 hex pairs.

    When creating Sprite Assets, you can also assign unicode values and names to individual Sprites / Emojis.
     
    Saicopate likes this.
  4. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    Stephan, this is what I needed to know, thank you.
    After some testing I found out that there are 16 emojis delivered with standard TextMeshPro package. Previously I had a feeling that all of them are mapped because I tested two emojis and they happened to be within these 16 :p