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 TMPro SetText with format incorrectly shows leading zero for some ints

Discussion in 'UGUI & TextMesh Pro' started by AndyUr, Nov 15, 2019.

  1. AndyUr

    AndyUr

    Joined:
    Aug 17, 2015
    Posts:
    19
    Hi!

    Right now some big ints get an incorrect leading zero.

    The code
    Label.SetText("{0}", 99999);
    shows 099999.

    Adding more nines at line TMP_Text.cs:3390 fixes it for my case.


    } while (number > 0.999d);
    // Change To:
    } while (number > 0.999999999999999999999999999d);


    I'm running version 2.0.1

    PD: Can you version control changes to packages?
     
  2. Quasimodem

    Quasimodem

    Joined:
    May 21, 2013
    Posts:
    52
    I've recently hit exactly the same issue. Would love to have this fix rolled up in the official package since maintaining local changes to a package is very fragile and difficult to distribute.
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I made the following change which will be in the next release.

    Code (csharp):
    1.  
    2. do
    3. {
    4.     m_input_CharArray[i++] = (char)(number % 10 + 48);
    5.     number /= 10;
    6.     integralCount += 1;
    7. } while (number > 0.999999999999999d || integralCount < padding);
    8.