TextMesh Pro object 100ms frame when .SetActive(true)

Hi,

I hope this is the right sub-forum for my issue.
I have a TMP gameobject which I set active when the player comes close and set inactive a few seconds later. This causes a stutter of ~100ms, but only the first time it is being set active after loading a scene. Afterwards there is no stutter at all, until I reload the scene. This also happens when I build the game, not only in the editor.

I cannot enable / disable the Mesh Renderer as the object contains a few scripts which need enabling / disabling at the same time. If the TMP - Text component is disabled, there is no framerate stutter when setting the gameobject active.

Any ideas I could address this?

Most likely the issue is related to all TMP resources needing to be initialized in the event this is the first TMP object being initialized. Then you have the Awakening of the text object itself which has it own overhead.

One potential solution would be to Set these text objects active when the scene is loaded and then disable them once loaded. This would result in all this initialization taking place at a less crucial time where subsequent enabling / disabling would no longer be an issue.

Let me know if that might work for you.

In terms of the overhead, keep in mind that deep profiling usually reflects a 5 to 10x slower performance then in a real build but overhead none the less. Furthermore, if the stutter is noticeable in the build then of course it makes sense to look for ways to avoid it.

Nice and easy solution, thanks!
I wasn’t aware of the necessity of initialization of resources with the first TMP object in the scene. Good to know it’s something so straight forward.