Search Unity

How to set a sprite inline with TextMeshPro?

Discussion in 'UGUI & TextMesh Pro' started by ndmrzk, Jan 2, 2020.

  1. ndmrzk

    ndmrzk

    Joined:
    Jul 25, 2018
    Posts:
    35
    Hello! I'm trying to have a sprite as a part of my text using Rich Text format but to no success. I've seen a few questions but with no concrete answers or even answers but I haven't been able to achieve this.

    I've already added the sprite i want inside "Assets > TextMeshPro > Resources > Sprite Assets"

    tmp2.PNG

    But the sprite character table is empty. Shouldnt the sprite be visible here or it doesnt matter? I've tried adding
    <sprite="SpriteAssets" name="SpriteAtlas">
    even like the other way around because I'm not actually sure which goes where. But the sprite isnt visible just all that as text.

    TMP.PNG tmp1.PNG

    Images attached for more details. Any help is much appreciated.
     
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Ryiah likes this.
  3. ndmrzk

    ndmrzk

    Joined:
    Jul 25, 2018
    Posts:
    35
    Hi @angrypenguin please don't be mad but just want to verify. So it has to be a sprite sheet? Cause i only want to use 1 sprite image.

    and noted about the subforums. thanks!
     
  4. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    I haven't double checked, but I assume so. It's ok to have a sprite sheet with just one sprite in it.

    Most people will need more than one sprite, and it would be inefficient for TMP to load every image separately, so encouraging you to put them all on shared sheets makes a lot of sense.
     
  5. ndmrzk

    ndmrzk

    Joined:
    Jul 25, 2018
    Posts:
    35
    Ahhh.. Okay! Figured it out via the links u shared. Thanks! New to setting up sprites well to unity sort of. Thank you.

    So for future reference (Coz I'm dumb like that):

    Basically, if its just one image you can still set it as multiple then in the Sprite Editor just size the transform box to fit the image you want. Note the name of the sprite when you are doing this.

    sprite editor.PNG

    Then on the image, right click on it Create > Text Mesh Pro > Sprite Asset and it will create the sprite asset which will have the same name as the image but with like a blue icon with an S. I moved it to Assets / Text Mesh Pro / Resources / Sprite Assets , this step needs to be done in order for it to work.

    Then in your Text Mesh Pro in the text field use
    <sprite="name of sprite atlas" name="name in sprite character table">


    sprite character table.PNG

    Then you may handle it positioning etc in the Sprite Glyph Table

    And done. Tada!
    yeay.PNG