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

"String too long for TextMeshGenerator. Cutting off characters."

Discussion in 'Scripting' started by soxroxr, Sep 2, 2015.

  1. soxroxr

    soxroxr

    Joined:
    Jul 17, 2012
    Posts:
    60
    I keep getting the above mentioned error; "String too long for TextMeshGenerator. Cutting off characters."

    I'm sure it's because I'm hitting the vertex limit or something similar, but my game relies on the player entering a lot of text (for the purpose of writing) and the testers apparently keep getting this error when the text gets too long.

    Is there any way around it?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    Can you break it up by paragraph into different mesh objects? Can you cull non-visible paragraphs?
     
  3. soxroxr

    soxroxr

    Joined:
    Jul 17, 2012
    Posts:
    60
    I'm not sure how to do that functionally while letting the player go back and edit something if they want.
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I'm running into this today... and so far, my googling only turns up a lot of other people with the same question, and no real solutions. :(

    I wonder if the new TMPro integration will fix it? Possibly. Or else, somebody really needs to make some new Text (and InputField) components that don't suck.
     
  5. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    I noticed I'll get this error with TMPro as well. It's a limitation of Unity and I guess how it handles text. TMPro does have an option to auto split text beyond one box so if the text gets to large, it will spill over to another box, but I don't think this works with inputfields.

    If all you're doing is pure text without anything else, I don't think TMPro will help any. I don't think I ever found a good solution to this yet, but I'm interested if anybody finds something as we're doing a book app right now and we may run into a page that with the formatting tags may end up to large.
     
  6. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    Anybody knows what this limit is precisely? Knowing this number will let us cap/split strings accordingly
     
  7. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    16382*

    one char more and error
    *according to GUILayout.Label (2017.3.0p3)
     
    sonnyb likes this.
  8. networm

    networm

    Joined:
    Sep 15, 2015
    Posts:
    8
    @andrew-lukasik 65535/4 = 16383.75
    It seems that Label uses 4 vertex per character to construct mesh.
    16382 is just below 16383.75
     
    andrew-lukasik likes this.
  9. sunwangshu

    sunwangshu

    Joined:
    Mar 2, 2017
    Posts:
    21
    Agreed, my Text in UGUI triggers this error when I had around 16482 characters