Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

[solved] Text Mesh Bounds While Reading

A topic by DKYGames created Jun 08, 2018 Views: 429 Replies: 3
Viewing posts 1 to 4
(1 edit)

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

Developer

Just updating this to let you know that this has been implemented for the next update. It's still going to take just a bit longer since I'm working out other bounding box issues, but I now have variables that track text bounds as the mesh reads out, the final bounds that text will have when it finishes reading, as well as an OnPrintEvent() that gets invoked every time a new character is drawn, so that can be used to update the size of a mesh.


-Kai

Awesome! Thanks!

I had implemented something similar to your previous suggestion. Got it working after a bit of trial and error.

However having characters' speech bubbles grow as the words are read out is actually a bit difficult to follow along (as a user). Probably because I had the text center-aligned. But I'm sure there's other practical uses for this feature.

Thanks again for the continued support!