Search Unity

TextMesh Pro Emojis

Discussion in 'UGUI & TextMesh Pro' started by dadude123, Mar 14, 2017.

  1. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    makaka-org likes this.
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    See the following post on the TMP user forum.

    Note that I also added the ability to assign a fallback sprite asset which makes it possible to split those sprites into more than one sprite asset / sprite atlas texture. This became required as fitting over 1500 sprites into a single sprite asset was getting more challenging.
     
    xen23 and Deleted User like this.
  3. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Hmm, sorry, I can't find "texture packer" in unity. Or do you mean this third party tool?
    Somehow the forum post you linked to is somewhat confusing for me.

    Do we always start with all individual images and then generate our atlas on our own somehow? (Unity, or some tool?)

    Could you explain the steps needed to go from the source (either all those individual images, or alternatively the pre-made atlas from emoji one + the json file that describes the mapping) to being able to write <sprite ...> ?

    Also where and how do I assign that fallback sprite?
    Would I just give different packing tags in unity?
    I built my own atlas with the unity sprite packer but I don't see how I can select the atlas in the SpriteImporter, it doesn't appear in the list.


    edit:
    I figured out where to assign fallback sprite assets. But how to create a sprite asset from a folder of files is still not clear to me

    edit2:
    using texture packer I was able to make working texture sheets and import them with the text mesh sprite importer.

    The last thing I'm now missing is how to actually draw the emoji.
    I know that I have to replace the text where I want an emoji with <sprite=...>.
    But I don't have the sprite ID, just the UTF32 code.

    edit3:
    I made a script to get the sprite ID, but even if I have it, how would I write the correct ID so TMP knows which sprite asset to select?
    All the sprite IDs start at 0, so "Id 0" exists in 8 different sprite-sheets...

    Another problem is the pivot, the emoji are all offset (-32, +32)

    edit4:
    got the offset fixed by using the "global offset" thing :)

    Alright, this video cleared up almost everything.

    Only things remaining are:
    - Is there a (good) way to create a sprite sheet from multiple files without using TexturePacker?
    - Is there a way to import the json from the emoji one github? (I guess writing my own converter should be super easy as long as all information is there, but I don't want to work on something that may not even be necessary)

    bug report: <sprite name="..."> doesn't work when the name is in a fallback sprite asset, my fallback sprite asset list is set populated correctly.
     
    Last edited: Mar 14, 2017
    xen23 likes this.
  4. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Hmm, it seems like there's nothing I can do:



    The sprite assets are setup correctly..



    @Stephan-B Any idea what the issue could be?
     
    xen23 likes this.
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This is in fact an oversight on my part :)

    Basically, the fallback doesn't work with the name or index attribute of the sprite tag. Although I don't think it makes sense to have the index be used to search through fallback sprite assets, it most certainly makes sense on the name part which I will be looking into.

    In the meantime, please note the following:

    The unicode value does work with the fallback sprite assets. So assuming you assigned the unicode value of "1f3c4" to a sprite in the primary sprite asset and something like "1f42e" to a sprite in one of the fallback sprite assets, typing the following would pull up the sprites.

    "Sprite 1: \U0001f3c4 Sprite 2: \U0001f42e"

    BTW: <sprite name="some name"> refers to the sprite with the name "some name" located in the default sprite asset defined in the TMP Settings file. <sprite name="some other name"> would still result in searching through the same sprite asset and not the fallback.
     
  6. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Awesome, that actually did the trick!

    In the video you didn't mention that you have to use the unicode codes.
    I thought the only way was to "address" the sprite by name or ID.

    But there is one other issue that I think is caused by the sprite importer.
    Its best illustrated by an example:

    Lets say I want to display the emoji: 1f3c4-1f3fb (Surfing man, white skin color)
    Then isn't the unicode entry wrong!? (while the name is correct)


    The unicode thats written there is ambiguous, but the name is correct.
    How would I display the emojis that use those surrogate pairs?

    When I just write \U0001f3fb it doesn't work right:


    The source data from texture-packer contains the correct code, and the sprite asset also gets the correct name assigned, but the unicode seems to be missing the "left" side.

    edit: I mean I can write \U0001f3c4 and then I get the surfer with white color, but how do I write different skin colors?

    For example "U+1F3C4 U+1F3FF" (surfing man, skin tone: dark)

    Another example:
    U+0023 U+FE0F U+20E3
    None of those alone works, and I can't figure out how to combine them into one single unicode entry

    Copy pasting directly from a website doesn't work either:
    Code (CSharp):
    1.  
     
    Last edited: Mar 15, 2017
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Emoji modifiers as well as sequences which is what you are describing here is not supported yet. It is on the list of features I am planning on adding.
     
    xen23 and dadude123 like this.
  8. Dark_Wizard123

    Dark_Wizard123

    Joined:
    Dec 14, 2016
    Posts:
    10
    @dadude123 - Do you have a link where I can find all the latest emoji? Do you think there is a copyright involved with the images mentioned in your first link?
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Here is a link to EmojiOne where you can review their licensing options.
     
  10. Dark_Wizard123

    Dark_Wizard123

    Joined:
    Dec 14, 2016
    Posts:
    10
    @Stephan_B - any update on surrogate pairs emoji ? Is there any alternative to show surrogate pairs.
     
  11. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789

    If you already have an atlas that contains all the emoji, then you can always just manually insert sprite tags into the text.
    Using the json file that texture packer applications generate, it should be trivial to do a .Replace(...) on all text that simply replaces the corresponding symbols with the right sprite tag.
     
  12. Dark_Wizard123

    Dark_Wizard123

    Joined:
    Dec 14, 2016
    Posts:
    10
    @dadude123 - I am not doing it manually. I am using it for chat application so I believe emoji correspoding to unicode would be shown
     
  13. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Do you mean Emoji sequences or surrogate pairs to define a UTF32 character?
     
  14. Dark_Wizard123

    Dark_Wizard123

    Joined:
    Dec 14, 2016
    Posts:
    10
    Problem is when you tap on the surrogate pair they don't show the right emoji although I have them in the sprites. The problem is not limited to surrogate pairs but with some normal emoji i.e U+2639 (Maybe we're not supporting 4digit Unicode).
     
  15. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I don't fully understand the issue you are reporting in the sense that TextMesh Pro does support both UTF16 and UTF32 which means whether the character, emoji or sprite is mapped to a UTF16 (4 digit as you call it) or UTF32 (8 digit to stick with your descirption) TMP can access them.

    Can you provide more details or perhaps a simple Repro project for me to look at so I can understand clearly what issue you are having?
     
  16. MacFBG

    MacFBG

    Joined:
    Jan 23, 2016
    Posts:
    18
    Just wanted to add another voice to the thought that sprite name support for fallback assets would be a lovely feature. I ran into this issue as I had assumed this is how it would work. Eventually found out that I could use Unicode. I'm a bit new to sprite assets so I don't really understand how the Unicodes work.

    I initially manually just put 7 in as a unicode and then attempted \U0007 but this didn't work, upon entering your example 1f42e and typing \U0001f42e I was able to get my fall back sprite to appear. But with 20 sprites in my sheet it feels odd entering random unicode values to get this fallback functionality working.

    I appreciate this confusion is down to my complete lack of understanding of Unicode.
     
    Last edited: Feb 14, 2018
  17. MacFBG

    MacFBG

    Joined:
    Jan 23, 2016
    Posts:
    18
    Unrelated to the above, I create a Sprite Asset from a .psd sprite sheet. I then went back to the .psd and added some more sprites and spliced them up. However when I look back at my Sprite Asset, these new sprites are showing in the Sprite List. Do I need to do anything to update that list? I'm hoping I don't need to create a new Sprite Asset as I've already attached this one as a property on several game objects.
     
  18. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Emojis on Desktop and Mobile devices actually have Unicode values assigned to each of them. See the list here.

    The reason why /U0007 didn't work is because /u (lowercase) is for UTF16 and /U (uppercase) is for UTF32.
     
  19. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    When you update the texture, you will need to again use the Unity Sprite Editor to define those new sprites and then re-generate the Sprite Asset. See the following post.

    In terms of regeneration of the Sprite Asset, this is something that I'll look at simplifying / improving when I have time.
     
  20. dyates

    dyates

    Joined:
    Aug 18, 2015
    Posts:
    2
    @Stephan_B any news regarding supporting Sprite Asset fallbacks via sprite name? I'm also trying to use multiple Sprite Assets for emojis and assigning fallbacks as needed at runtime. Currently referencing any sprite in the fallback assets by name isn't working. Also I can't switch to using the Unicode values because I am supporting all emoji modifiers and it doesn't look like TMP supports that yet.
     
  21. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Is the need for being able to use the sprite name solely related to emoji modifiers?
     
  22. dyates

    dyates

    Joined:
    Aug 18, 2015
    Posts:
    2
    @Stephan_B yes since our goal is to be able to handle any emoji character that the user can type on their device. We had this supported before by using sprite name with just one very large sprite atlas, but we are looking to reduce the memory overhead of that by splitting up the emojis into multiple atlases.
     
  23. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I'll provide a more definitive update tomorrow but I should be able to get this functionality in the next release of TMP which will first be available for Unity 2018.1 via the package manager and then subsequent releases for 2017.1, 2017.2 and 2017.3.
     
    dyates likes this.
  24. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Any update on that topic?
    Currently working in 2017.4 and i do not have any way to handle Emoji modifiers / sequences.
     
  25. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    No updates. This features is part of the larger planned support for OpenType Font Features.

    Do you need full support for modifiers or just a way to reference those sprites / emoji?
     
  26. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,163
    Now 2018.2 are there any progress yet?
     
  27. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,163
    Now is 2018.3 how is the larger plan progress so far?
     
    Novack likes this.
  28. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Slowly getting there. First of the new major features will be in the next release of the TMP UPM package for Unity 2018.3 which should be available in the next 30 days or so.

    New features use a new low level API that is currently only available in Unity 2018.3. Once released for Unity 2018.3, I am hoping to back-port to Unity 2018.1 and 2018.2 and maybe 2017.4 (no promises but would like these new features to be more widely available).

    Improved Emoji support is not part of this next release. However, once this new low level API and new major feature is available, subsequent new features should come more quickly and in subsequent package updates.
     
    Thaina likes this.
  29. sophieannebusog3

    sophieannebusog3

    Joined:
    Mar 18, 2019
    Posts:
    5
    Is this resolved already?
     
  30. Rafael_CS

    Rafael_CS

    Joined:
    Sep 16, 2013
    Posts:
    162
    Brogan89 likes this.
  31. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,163
    Now it's 2019.3 how is the ` larger plan ` progressed so far ?
     
    cxode likes this.
  32. unitylicense19

    unitylicense19

    Joined:
    Aug 29, 2018
    Posts:
    32
    any update on the emoji modifiers?
     
  33. VladimirGordeev

    VladimirGordeev

    Joined:
    May 16, 2017
    Posts:
    11
    2 years! Where emoji Ilon Mask ?
     
  34. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,023
  35. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    Hey @Stephan_B , could we get a status update on emoji modifiers? I'd really like to have full emoji support in my game.
     
    Last edited: Jul 2, 2021
  36. nyonge

    nyonge

    Joined:
    Jul 11, 2013
    Posts:
    49
    @Stephan_B bump :) I'm looking to add emoji support to an app as well
     
    makaka-org likes this.
  37. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I am planning on adding support for Emoji modifiers / Ligatures in this current TMP package preview cycle. Ie. in one of the previews of version 1.6.0 for Unity 2018.4, 2.2.0 for Unity 2019.4 and 3.2.0 for Unity 2020.x or newer.
     
    cxode, firstuser, makaka-org and 2 others like this.
  38. jiraphatK

    jiraphatK

    Joined:
    Sep 29, 2018
    Posts:
    300
    Hi, have emoji gotten support in the new version yet?
     
  39. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Support for Ligatures will be in the next preview release. I will try to also have support for Emoji modifiers as well.
     
  40. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    Thanks for the update Stephan, looking forward to it!
     
  41. Lukas-Labaj

    Lukas-Labaj

    Joined:
    Nov 22, 2012
    Posts:
    36
    Hello @Stephan_B, I think Emojis did not get it to the last release 3.2.0-pre2, any ETA for that please?
     
  42. SyedUmair

    SyedUmair

    Joined:
    Sep 2, 2013
    Posts:
    43

    Hi, I have created a sprite atlas via TexturePacker and imported it inside unity and created sprite asset via Sprite Importer tool of TMP. But the sprite asset created in result don't have correct values for Unicode, though sprite names are set as respective hex values.
    Am I missing something or do I have to set all those (almost 1000 images) unicode values manually?

    Thanks
     
  43. ETGgames

    ETGgames

    Joined:
    Jul 10, 2015
    Posts:
    101
    Where are emoji modifiers? It's 2024
     
  44. hery8

    hery8

    Joined:
    Mar 9, 2024
    Posts:
    1
    thanks for share nice post.
     
    Last edited: Mar 26, 2024