Search Unity

TextMesh Pro Alternate underlines supported?

Discussion in 'UGUI & TextMesh Pro' started by ibyte, Apr 23, 2020.

  1. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    Hello we need to support a spell checker in our app and wanted to use an alternate underline character in place of the straight underline. I assume a new tag would also be needed to allow for both to exist in the same document?

    Any chance of this support being added?

    Glenn
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What do you have in mind so I can get a better understanding? Can you provide an image?

    How much text will you be underlining? You can always create you own geometry and use the information contained in the textInfo to position your alternative underline.
     
  3. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    Hi Stephan, Spellcheck would like to see exactly what we see when editing a forum post here.

    How would i add suuport for a custom tag and reuse as much of the existing underline code as possible?

    upload_2020-4-26_11-49-35.png
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Instead of trying to reuse the underline, I would recommend implementing your own solution where similar to how underline is handled, you create the geometry (most likely a simple quad) pointing to some repeating texture of some wavy line which would position wherever you need.

    By using the information contained in the textInfo such as wordInfo, characterInfo, etc. you can determine the exact position of each word along with first and last character to create and position each of these lines.

    This type of implementation would be more efficient than using rich text to insert these lines as this would require a re-layout of the text whereas having this implemented as per the above would not.

    See the following old post and script example. The example code may no longer work but the general idea remains the same. Look at examples like 23 - Animating Vertex Attributes and 12- Link Example and relevant scripts included in the TMP Examples & Extras as these contain updated code samples and should prove useful in understanding how to access and use the information contained in the textInfo to achieve the results you seek.
     
  5. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    That you very much for the solution. I have implemented it but I see that extra geometry for the underlines is not being clipped by the inputField that the text field is located in? Suggestions?

    upload_2020-5-1_3-15-36.png

    upload_2020-5-1_3-16-35.png
     
    Last edited: May 1, 2020
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You will need to make the script that handles this special underline inherits from MaskableGraphic and I think that should work.