Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Using One-Off Sprites + Atlas in TextMeshPro

Discussion in 'UGUI & TextMesh Pro' started by Mhin-Ra, Mar 3, 2023.

  1. Mhin-Ra

    Mhin-Ra

    Joined:
    Mar 29, 2015
    Posts:
    6
    I've got a standard sprite atlas I'm using for most of my text icons. However, in some cases, I would like to include one off images into text runs. I'm basically trying to do something like an <img> tag from HTML inline with my text, a la:
    upload_2023-3-3_9-10-48.png
    So, imagine in the above example the smiley faces come from my atlas and the cat is just a freestanding sprite.

    I want to do this b/c the game has a bunch of text conversations which should have inline images. It would be awkward to have to insert every image that might occur in any conversation into my text glyph atlas, both from an authoring point of view and because the inline images will all be random sizes. However, I still want all my conversations to have access to the 'standard' glyphs (for my game) from my atlas, a la:
    upload_2023-3-3_9-13-32.png

    I read a post by Stephan that seemed to suggest you could directly reference a standalone sprite with a tag like <sprite="wreckedShip">, where wreckedShip is:
    upload_2023-3-3_9-19-45.png

    upload_2023-3-3_9-19-22.png
    Although he cautioned that this would incur an extra draw call. For big, relatively rare images, that cost seems acceptable. But I've not managed to get it to actually work.

    Am I barking up the crazy tree or can this be done? And if so, would it be possible to get a step by step on how to set it up b/c I seem to be missing some part of the workflow?
     
  2. tnordstromgala

    tnordstromgala

    Joined:
    Dec 13, 2022
    Posts:
    1