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

Apparent String Length Limit???

Discussion in 'Scripting' started by hai_ok, Sep 23, 2009.

  1. hai_ok

    hai_ok

    Joined:
    Jun 20, 2007
    Posts:
    193
    I have been appending debug.log-style data to my own string as events happen.
    it is displaying in a scrolling label I think.
    Kind of a forensics effort to reconstruct things so I don't miss what happens.
    A practice I highly recommend.

    I have reached a point where I can no longer append to the string.

    I can clear it and then it keeps appending at runtime. but it always fills up again.

    Is there a known limit?

    if so, perhaps I should be writing out to a file instead.

    and if that's the case, how would Unity be able to read that if it were too long?
     
  2. launchpad

    launchpad

    Joined:
    Aug 17, 2007
    Posts:
    95
    Hi,

    I have experienced the same issue. A scrolling window not able to display the entire text file. But I have been able to read and write the file, as well as send it to a server without problems.

    Therefore I believe it is only a variable display limit, not necessarily a string size limit.

    Regards,

    Peter
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Unity has a maximum of ~65K vertices per object, and since text is constructed from polygons of 4 vertices each, the maximum number of characters that can be displayed at once in the Unity GUI per object is 16,384. To display more than that, you'd have to break up the text into more than one object.

    Edit: actually the character limit seems to be 16,382; must be reserving a few vertices for something else then.

    --Eric
     
  4. hai_ok

    hai_ok

    Joined:
    Jun 20, 2007
    Posts:
    193
    thanks you guys!
     
  5. zevonbiebelbrott

    zevonbiebelbrott

    Joined:
    Feb 14, 2021
    Posts:
    118
    I just ran into this same problem as I have a chat system for an online game, instead of adding a new UIMessagePrefab for every message I am also appending text to a single string and displaying that in Rows.
    Is the limit still 16.3K characters or has this changed in the last 15 years?

    Thanks