Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro issue when overflow is set as page

Discussion in 'UGUI & TextMesh Pro' started by gyd, Nov 28, 2019.

  1. gyd

    gyd

    Joined:
    Nov 9, 2012
    Posts:
    15
    hi, @Stephan_B
    please check this.

    Unity : 2018.4.13f1
    Textmesh pro: 1.4.1 / 1.5.0 preview 2 tested

    1. the PageInfo is not updated after ForceMeshUpdate is called, my workaround is waiting for one frame.

    2. the PageInfo[page].lastCharacter is wrong when the text is end of "\n" (maybe the same on other escape characters ), for instance

    text: "This is a test string"
    textInfo,characterCount: 21
    pageInfo.firstCharacterIndex: 0
    pageInfo.lastCharacterIndex: 20

    text: "This is a test string\n"
    textInfo,characterCount: 22
    pageInfo.firstCharacterIndex: 0
    pageInfo.lastCharacterIndex: 0 => should be 21

    3. the character index is not correct for <br> tag, because <br> is replaced by "\n", for instance

    text: "<br>This is a test string"
    textInfo,characterCount: 22 => correct
    pageInfo.firstCharacterIndex: 0
    pageInfo.lastCharacterIndex: 21 => correct
    textInfo.characterInfo[0].character = "\n" => correct
    textInfo.characterInfo[0].character.index = 0 => should be 3

    text: "<color=#ff00ff>This is a test string</color>"
    textInfo,characterCount: 21 => correct
    pageInfo.firstCharacterIndex: 0
    pageInfo.lastCharacterIndex: 20 => correct
    textInfo.characterInfo[0].character = "T" => correct
    textInfo.characterInfo[0].character.index = 15 => correct
     
    Last edited: Dec 5, 2019
  2. gyd

    gyd

    Joined:
    Nov 9, 2012
    Posts:
    15
    any luck?
     
  3. gyd

    gyd

    Joined:
    Nov 9, 2012
    Posts:
    15
    bump
     
  4. CoderDragon

    CoderDragon

    Joined:
    Jan 19, 2016
    Posts:
    1
  5. kiferdon

    kiferdon

    Joined:
    Aug 14, 2018
    Posts:
    15
    @Stephan_B We really need your help)
    Unity 2018.3.4, TMP 1.30 verified
    PageInfo lastCharacterIndex equals 0 in some cases
     
    Last edited: Jun 9, 2020
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Please test using the latest release which is version 1.5.0-preview.14.
     
  7. kiferdon

    kiferdon

    Joined:
    Aug 14, 2018
    Posts:
    15
    It is not compatible with Unity 2018.3.4

    Error:

    Library\PackageCache\com.unity.textmeshpro@1.5.0-preview.14\Scripts\Editor\TMPro_FontAssetCreatorWindow.cs(11,19): error CS0234: The type or namespace name 'TextCore' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)

    Can you suggest another version of TMP?
     
  8. kiferdon

    kiferdon

    Joined:
    Aug 14, 2018
    Posts:
    15
    Versions 1.4.1 and 1.5.0.1 don't help neither
     
  9. Vansoul

    Vansoul

    Joined:
    Oct 6, 2017
    Posts:
    1
    That issue still break my brain!
     
  10. Jinkata

    Jinkata

    Joined:
    Jul 10, 2017
    Posts:
    1
    I know I'm late to the party, but I ran into this too. Can anyone confirm this as a fix?
    in TMPro_Private.cs
    I changed this on line 3263
    Code (CSharp):
    1.  else if (m_characterCount == totalCharacterCount - 1)
    2.                         m_textInfo.pageInfo[m_pageNumber].lastCharacterIndex = m_characterCount;
    to this
    Code (CSharp):
    1.  else if (m_characterCount == totalCharacterCount)
    2.                         m_textInfo.pageInfo[m_pageNumber].lastCharacterIndex = m_characterCount;
    The code seems to revert after restart, but I'm not sure it recompiles when it reverts, because I haven't had any issues since I've changed it. The lastCharacterIndex is set to 0 by default, and the if/else block they have setup would allow something fall through and just stay at that default.
     
  11. tweedie

    tweedie

    Joined:
    Apr 24, 2013
    Posts:
    311
    Just came across this - PageInfo.lastCharacterIndex will return 0 if the text's string ends with a newline character. This is a very easy issue to lose a lot of time to, would greatly appreciate it getting fixed!