- Home /
"String too long for TextMeshGenerator. Cutting off characters." when doing Regex.Replace
Hi,
When executing
newstring = Regex.Replace(oldString, oldSubString, newSubString);
I get the following errors:
"String too long for TextMeshGenerator. Cutting off characters." "count <= std::numeric_limits::max()"
My string size is around 15000 characters and I am using Unity 5.1.1f1 (64-bit)
I have looked around for a solution but can´t find anything, any ideas or workarounds?
thanks!
That error is most likely not co$$anonymous$$g from that line, but from passing that string to a TextArea. It's a limitation of TextArea where past a certain number of characters, it will simply refuse to render them, even though the text will still be there internally (scrolling to the end of the TextArea and deleting some characters shows this).
You are right, I don´t get the error from the Regex, I actually get it when I try to run GUILayout.Label (newString) after the replace. The Regex.Replace is causing the string to go from roughly 10k to 15k characters and I am guessing thats too much for GuiLayout.label, although the error messages don't point to any specific line in the code and they appear 3 times each...I will just split the text and render several labels, thanks
I'm getting the same error, only after upgrading to 5.1.1f1. It's different each run, sometimes it throws at 700 characters, sometimes at 1300 characters, and other times at 2000+ characters. I have no clue whats causing it, but my chat areas are officially broken after the upgrade.
Answer by zzzzz · Jul 29, 2015 at 10:28 AM
The problem is you probably have it as a PUBLIC variable and therefore it shows in the INSPECTOR and the inspector is using GUI and GUI text fields are limited in size. I had the same problem but I do not know how to hide it from the INSPECTOR (I need it to be public)... Anyone?
That is actually a different error that will throw on the inspector, this error has nothing to do with any inspector fields. This error is thrown within the Text class itself and originates from the TextGenerator on the object in your scene.
Add the attribute [HideInInspector] above your variable.
Answer by bkachmar · Aug 18, 2015 at 02:19 PM
I had the same problem and restarting Unity solved it.
Answer by sjpt · Dec 28, 2015 at 07:40 PM
Make it public in another class and the Inspector won't see it.
Even simpler, if you're in C# you can convert the field to a property, as Unity won't serialize the property.
Before:
public string $$anonymous$$yString;
After:
public string $$anonymous$$yString { get; set; }
This is of course assu$$anonymous$$g that the issue was the text being too long for the editor GUI. If the issue exists outside the editor, this won't solve anything.
This $$anonymous$$ethod work,Thank you very much