C# - how do I get the number of lines in a TextMesh

i’ve found information concerning TextGenerator, but this just seems way too complicated for such a simple thing. I would like to find the exact number of lines on a TextMesh, counting the horizontal overflow. I just want there to be something like: TextMesh.CountLines or something.

I have a GameObject with a TextMesh component and whenever I change the text, I want to then count the lines and change a spriteRenderer to have a speechBubble appropriate in size. Is this easy to do or do i need to go and figure out this TextGenerator thing?

You can use textInfo.lineCount from your TextMeshPro reference.

textMesh.text.Split(’
').Length