Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

TextMesh from zero to hero

Discussion in 'UGUI & TextMesh Pro' started by Leggy7, Nov 15, 2016.

  1. Leggy7

    Leggy7

    Joined:
    Feb 18, 2014
    Posts:
    21
    Hello, I was wondering if anybody could provide me some guidelines in using TextMesh component.

    I cannot approach it on my own and I'm having an hard time in finding any tutorial or understandable manual. I think I'm missing some very basics like the rendering material array, the material setup (shader and whatever is necessary to work with this component) and the font type, size, line spacing.

    I have the feeling that all these things play their role in making the component behave as per expectations but I can't really sort it out.

    Final goal is to use it to render inline images along text. I think it could be done by using the quad tag but the related documentation doesn't help me enough.

    Any help would be appreciated
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Put font in project, make GameObject with TextMesh component, drag font from project onto TextMesh font slot. Change the font size in the TextMesh component to something like at least 30-40, depending on how big the text will be on-screen. The rest is arbitrary and depends on how you want it to look, although it's likely you'd reduce the character size after increasing the font size, so it looks high-res.

    For quads, make a material, set shader (probably unlit/texture), add a texture. Drag the material on top of the Materials slot in the mesh renderer component to add it to the materials array (or else manually change the size of the array and drag the material onto the appropriate slot). The element number for the material in the array is the number you use to tell the quad tag which texture to use. When using the quad tag in text, set x/y/width/height as appropriate to select what part of the texture you want to draw. e.g., if you want to use the entire texture, x=0 y=0 width=1 height=1. If you made a texture atlas where you had different parts in, say, a 2x2 arrangement inside a single texture, x=0 y=.5 width=.5 height=.5 would be the upper-left quarter. (Texture coords are bottom-up, so 0,0 = bottom left.)

    --Eric
     
  3. Leggy7

    Leggy7

    Joined:
    Feb 18, 2014
    Posts:
    21
    Eric, a really big thank you. Would be that simple and appropriated to copy paste what you just said here into the documentation. I really went mad to try (and fail) to understand how to use this component. That wasn't obvious (and it still is a little bit confused) and a little huge help like what you provided was the charm I was looking for. Now I think I'll be able to toy for a while with this, until next immovable obbject on my way.

    Maybe this thread will be kept living for a while longer!
    Good bye,
    Luca