Unity 2019.3.1
TMP 2.1.0-Preview8
I’m trying to render a prefab that contains a maybe a 9 text mesh pro labels to a texture. The downside is that I seeing two frames of pretty expensive TMP operations to generate the mesh that I’m wondering if there’s a way to get around. The labels I’m using are not UGUI TextMesh Pro labels as these labels exist in world space and are rendered by a camera that is culled to only render the labels.
The first frame is when we instantiate the prefab that contains the large amount of text. I needed to deep profile in order to get the call stacks (I’m aware of the overhead, but from what I can gauge it is also what is causing the hitch in play mode).
Note that the time isn’t spent allocating the buffers for the arrays, but rather generating text because as I mentioned the text is very long (paragraphs of text). The next frame when I try to render a disabled camera to texture using Camera.Render() I’m getting another hitch as it regenerates the mesh data again for the camera render for the exact same labels.
The result is that there is a significant frame rate drop due to these subsequent long frames of calculation. I think I’d be OK with one frame, but the fact that this mesh is being generated twice when the text hasn’t changed is concerning me.
Another interesting thing is that while there are only 19 calls to TextMeshPro.Rebuild there are 136 calls to GenerateTextMesh! Is there maybe some duplicate calls to force rebuild the mesh in the code?
If anyone has any tips to avoid this I’d appreciate it.