Search Unity

Question Text Mesh Pro - How to map texture per word in text (or within a tag)

Discussion in 'UGUI & TextMesh Pro' started by JVCA0606, Jan 26, 2024.

  1. JVCA0606

    JVCA0606

    Joined:
    Jun 15, 2019
    Posts:
    3
    I have an block of text, where some of the words need to have an gradient effect applied to them. I could not use TMPs built in gradients as they cannot be applied on per word basis (only a per character one). So instead, i opted to make a gradient texture, and just use <font="my font" material="gradient_material">word</font>.

    This works well, except for an small issue: Since the horizontal map mode is set to line (anything else will not have the desired effect), when I try to use this gradient effect within a big blob of text (for example:

    • Hello, this is a test string for no other purpose whatsoever <...>wordWithGradient</...>

    My gradient texture will be streched to fit the entire line, resulting in "wordWithGradient" only having the final part of the gradient effect.

    How can I fix this? If there's a way of either limiting texture streching to each word, or to just within a tag, thats enough for my use case. I don't need both, either will work. Thanks in advance