I need to display our game’s privacy policy, and there are > 4000 words in it. Whenever I try to display the privacy policy text using UI.Text, I this exception in the console:
String too long for TextMeshGenerator. Cutting off characters.
I wouldn’t doubt it if UI.Text wasn’t designed to handle this much text. If this is the case, is there some sort of plugin to display vast amounts of text? I’d prefer it to be as simple as possible. I need to support iOS, Android and HTML5. I’m concerned about my options for HTML5.
Each Mesh / Canvas is limited to 65535 vertices. Since each character takes 4 vertices, you are exceeding this limitation.
When using a Mesh Renderer (instead of the Canvas) you can get around this by splitting the text into a few text objects. However, in the case of the Canvas (Canvas Renderer) all objects contained within the same Canvas count towards that total so splitting the text into different objects won’t help.
You will have to experiment with using multiple Canvas each with a part of the text to get around this or use the Mesh Renderer with the text split up between different objects. At 4000 words you have more than 1 page so maybe split it up by pages. Each page being an object.
Ok, I see. Looks like some one’s using an unsigned short for their index buffer’s format;) It’s a smart move, but it’d be nice if the canvas could re-allocate its index buffer to an unsigned int format when the vertex count gets near the uint16 threshold. It’d be a serious copy between GPU → CPU-> vector → cast/copy to vector → GPU → release vectors, but it wouldn’t be bad if the threshold wasn’t going back and forth as much.
I considered multiple pages, but that’s not doable right now. Is there a WebView plugin, or something similar to this to allow me to get around this? I’ve looked around the Asset Store, but I haven’t found anything that explicitly states that it supports HTML5/WebGL builds.
The vert limit is also there to prevent you from doing things that you shouldn’t. Canvases weren’t meant to manage so many verts, and performance would be even worse than it is if it did.
Best solution honestly is to just make it paged and display a portion of the content at the time. Then display only a portion of the text at a time, and have the user page through it. Having the user scroll through a 4000 word document manually without an I agree/page forward button is going to be a recipe for user disengagement.
Anyways, because that solution is problematic for some reason. Here are some alternatives.
- For the HTML5 deployment show the terms on the same page before displaying the unity5 content via some javascript. Then use a plugin for the Android/iOS builds.
- Do an Application.OpenURL() in the app that will redirect the user to the policy on another web-page.
these thread is 2 years old, so are there new solutions?
I’m interested too. I just need to display a EULA at the start of my unity iOS application.
i too wouldn’t mind a new solution aswell. need to display large chunks of a technical report.
The ideal solution for this is probably a specialized “TextScrollRect” that does virtualized layout/scrolling of a large chunk of text. That way you’d only use enough vertices to draw whatever text is currently on screen but I’m sure it’d be no small task to get that working correctly.
1 Like
Do you mean like the UI Scroll View?
I used it in a project for the same reason, EULA and TOS and Privacy. I noticed a lag on the computer (not a good one) and Unity crashed. Large amounts of text are apparently still being calculated but outside of the visible area.
I am currently experimenting with trying to pool the text like object pooling or else, the next best solution would be to split the text as mentioned before.
I have considered an external WebPage with the EULA and openURL to it as well but trying to keep all interaction in the app preferably.