🤑 Indie game store🙌 Free games😂 Fun games😨 Horror games
👷 Game development🎨 Assets📚 Comics
🎉 Sales🎁 Bundles

Text Mesh Bounds While Reading

A topic by DKYGames created 14 days ago Views: 33 Replies: 1
Viewing posts 1 to 2

I am trying to create speech bubbles that 'contain' text as it's being read. The bubble will only be as tall or wide as the currently visible text.

Right now I am setting the width and height of the containing transform using textMesh.bounds. However, this includes characters that are invisible while the text is being read. Also, if I apply any vertex effects then the bounds may be affected as well.

Is there a way to get the boundaries of currently visible text during a read? Bonus if it is not affected by jitter/wave effects - but for that I may just use a padding buffer.

Thanks, and loving the asset so far :)

Developer

Hey!


I was thinking about this the other day - this is a bit of a janky solution but it should work...


superTextMesh.info[superTextMesh.latestNumber].bottomRightVert should give you the equivalent of superTextMesh.bottomRightBounds, but for whatever the current letter being read out is. So if you keep track of this value and use Mathf.Max like this:


Vector3 furthestPoint = Vector3.zero;

//as mesh reads...

Vector3 point = superTextMesh.info[superTextMesh.latestNumber].bottomRightVert;

furthestPoint.x = Mathf.Max(furthestPoint.x, point.x);

furthestPoint.y = Mathf.Min(furthestPoint.y, point.y);



I'll try to add a variable for keeping track of this automatically in the next update!


-Kai