Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

TextMesh Pro Emojis

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

  1. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    611
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    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.
     
  3. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    611
    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
  4. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    611
    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?
     
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    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:
    611
    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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    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.
     
    dadude123 likes this.
  8. Arun_Appster

    Arun_Appster

    Joined:
    Dec 14, 2016
    Posts:
    9
    @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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    Here is a link to EmojiOne where you can review their licensing options.
     
  10. Arun_Appster

    Arun_Appster

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

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    611

    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. Arun_Appster

    Arun_Appster

    Joined:
    Dec 14, 2016
    Posts:
    9
    @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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    Do you mean Emoji sequences or surrogate pairs to define a UTF32 character?
     
  14. Arun_Appster

    Arun_Appster

    Joined:
    Dec 14, 2016
    Posts:
    9
    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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    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:
    16
    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:
    16
    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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    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:
    2,650
    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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,287
    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?