Search Unity

How to mix images into a text box?

Discussion in 'UGUI & TextMesh Pro' started by KevinCow, Aug 22, 2015.

  1. KevinCow

    KevinCow

    Joined:
    Feb 8, 2015
    Posts:
    8
    What I'm trying to do is have a text box that tells the player what button to push. But instead of saying, "Push the A button to jump," it should say, "Push (picture of A button) to jump".

    I've been trying to figure this out all night. I figure it has something to do with Rich Text, as I found here: http://docs.unity3d.com/Manual/StyledText.html particularly the part at the bottom about quads, but I can't for the life of me get it to work. I can't even get the color thing to work, actually, though for some reason Bold, Italic, and Size are working fine.

    After some Googling, I found some old threads here that seemed to vaguely touch on this but offer no solution.

    Surely there's a way to do this. It's such a basic thing.
     
    AtillaTheDev likes this.
  2. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The <quad> rich text tag doesn't work with UI.Text. It only works with the old TextMesh component.

    If you really need the ability to mix graphics or sprites inline with the text, you can take a look at TextMesh Pro which replaces UI.Text and offers a lot more functionality and rich text tags. More specifically, there is a <sprite=index> <sprite="name"> tag which allows you to do what you seek.

    Here is an example of using several sprites inline with the text.


    Here is a video which goes over how this feature works and how to create the Sprite Assets.


    Let me know if you have any questions about any of this or TextMesh Pro.
     
    Fbrzd likes this.
  3. KevinCow

    KevinCow

    Joined:
    Feb 8, 2015
    Posts:
    8
    Yeah, I encountered TextMesh Pro in my searches, and it seems like exactly what I need, but I'm not sure I'm ready to pay $65 just for that functionality. There's seriously no other way to do this?
     
  4. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I can see how having to spend $65 for just that functionality (if that is all you need) would seem like a lot. On the other hand, the ability to mix sprites and graphics inline with the text is just one of the many features available in TextMesh Pro.

    The main benefits of TextMesh Pro can be broken down into two things which are the Advanced Text Rendering and Dynamic Styling capabilities that it brings to Unity and the greatly improved text formatting and layout capabilities.

    The following video will provide a good overview of the Advance Text Rendering & Dynamic Text Styling capabilities of the tool.


    In term of Improved Text Formatting and Layout control, TextMesh Pro gives you control of Character, Line and Paragraph spacing as well as Kerning. There are now over 30 Rich Text Tags including the basics as seen in the image below to the more sophisticated <align>, <margin> and <link> tag to enable interactions with the text.



    Soon, I will be introducing a new tag <font> which will enable you to mix different fonts and materials per text objects. Here is an example of this below.



    TextMesh Pro was designed to replace Unity's text components whether it be TextMesh, GUI Text or the New Ui.Text by a much more powerful and flexible solution. Ultimately, the goal is bring to Unity and its users a text solution that is unrivaled in any game engine.
     
  5. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Here is an example of using the <font> tag along with the <sprite> tag where you can now mix different fonts and sprites within the same text object. This examples uses 4 different fonts and sprites.

     
    kungfufist likes this.
  6. Deleted User

    Deleted User

    Guest

    What! is TMPro not free like you said,("I can see how having to spend $65 for just that functionality").Need Help
     
  7. raonyfernandes700

    raonyfernandes700

    Joined:
    Jun 7, 2021
    Posts:
    3
    2015 bruh
     
    Hades714 and Deleted User like this.
  8. Deleted User

    Deleted User

    Guest

    Oh sorry about that i was not born in 2015 i was born few months ago