Search Unity

TextMesh Pro Can I assign a Sprite in TMP's Sprite Asset?

Discussion in 'UGUI & TextMesh Pro' started by Peter77, Jun 16, 2018.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    I was recently creating a new Sprite Asset, such as the one you can find in "TextMesh Pro/Resources/Sprite Assets/EmojiOne.asset".

    Unfortunately, adding all the images to an atlas texture and then having to specify the texture coordinates and size in the Sprite List for each entry is enormously time consuming and error prone.

    Is there a way to assign an actual Unity Sprite to the TMP's Sprite List instead? This would also allow me to use Unity's auto atlas generation via a Sprite Atlas asset later on.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Sprite Assets can be created by selecting a Texture set to Sprite (2D and UI) where the sprites have been defined using the Unity Sprite Editor and then selecting "Create - TextMeshPro - Sprite Asset" menu option. See the following video which covers this information.

    Sprite Assets can also be created using the "Window - TextMeshPro - Sprite Importer" where the sprites were added into a texture by using TexturePacker using the "Unity - JSON data (.txt) framework". See the following post.

    The sprites defined in the Sprite Asset contain additional data that normal Unity sprites do not contain. As such and to avoid confusion, I refer to them as Text Sprites. Although these text sprites reference the Unity Sprite, this is not necessary as the only data that maters are the uv coordinates into the texture which after the Sprite Asset has been created can be set to Default texture to avoid extra loading time when the texture contains several 100 sprites.

    In terms of the taking advantage of the Unity Sprite Atlasing, that is not supported yet but I certainly want to revisit that to further improve the workflow here.
     
    Peter77 likes this.
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    Thanks for the reply. The workflow is indeed not ideal, neither "Create - TextMeshPro - Sprite Asset" nor "Window - TextMeshPro - Sprite Importer". Let me explain why...

    Using a texture atlas workflow often causes version control issues, if multiple users change/add images that are located on the same atlas, since merging binary data is something version control software is bad at. Due to this limitation, we prefer to work with individual textures and use Unity's Sprite Atlas functionality (and because a tool can do this better anyway). It makes updating an individual sprite images much easier if you don't have to maintain an additional atlas texture.

    The "Sprite Importer" workflow has the disadvantage that I need to author the atlas in another program as well and then export its description file. Thus, I need the program/license and someone who knows how to use it.

    It would be more user- and workflow-friendly if TMP provides the ability to work with Unity Sprites. That way, the entire Sprite Asset creating can be done inside Unity and it could even benefit from Unity's advanced Sprite Atlas features such as tight packing.
     
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    I've added the following feedback item today. I hope you consider this, as it would improve the workflow how images are used in TMP tremendously.
    https://feedback.unity3d.com/suggestions/textmesh-pro-add-support-for-unity-sprite
     
  5. ihgyug

    ihgyug

    Joined:
    Aug 5, 2017
    Posts:
    194
    Hi,
    Any progress on this matter? Can we expect it to be implemented anytime soon?
    Thank you.
     
    linojon likes this.
  6. llMarty

    llMarty

    Joined:
    Dec 14, 2014
    Posts:
    33
    I'm interested in a better solution to this, too. @Peter77 your explanation resamples my own thoughts in the perfect matter and I think it's tragic that there is no further response.

    I think if Unity would use TMP as default Text implementation, those problems would be history, in any case.
     
    Peter77 likes this.
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Sprite Assets will continue to be necessary as Unity Sprites do not contain the relevant data for proper text layout.

    Sprite Assets are used to display inline graphics / sprites / custom icons and Emojis, etc. I am adding Face Info / metrics to sprite assets. See the relevant posts here.

    The Atlas Texture and where the sprites are located in terms of texture most likely could be revised to support the Sprite Atlas feature in some form (initially excluding tight packing to keep the geometry as quads).

    Note: Font Assets will soon gain the ability to contain colored glyphs mostly to support native emojis from font files. This will likely become to default way that users include support for Emoji in their projects. However, Sprite Assets will remain to make simpler to handle the need for Inline Graphics / Sprites / Custom Icons.
     
  8. robin_pcity

    robin_pcity

    Joined:
    Jun 26, 2020
    Posts:
    28
    Your referenced post-link doesn't work anymore. Would you mind updating it? I've been struggling with creating sprite assets, as I don't have photoshop so I hope that this post will do for me