Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Polygon bounds?

A topic by TeamLazerBeam created Jun 06, 2020 Views: 268 Replies: 11
Viewing posts 1 to 5

Is there a way to get the text to constrain itself to a custom polygon instead of a rectangle. It would be great not to have to use a rectanglular paragraph inside a of round speech bubble.

Developer (2 edits)

Hey!


This is a good idea, but not directly supported, and I'm not too sure how I would support it... It'd have to be a big update.

But, for the time being, I do have an indirect solution that already works!

Super Text Mesh has a "Pagination" feature, where text from one text box can be set up to automatically overflow into another. So... using this, you can set up multiple single-row Super Text Mesh objects that fill your round speech bubble, then just send the updated text to the first STM in the chain and... bam! Multiple STM objects can work as one.

If you have a static text box that will never change size, this won't take long at all to set up. If you have one that changes size dynamically... this might take a bit longer to set up, but it is possible. You'd have to systemically instantiate STM objects, and assign their position and autoWrap values based on the evaluation of the polygon at a given Y coordinate. If you need help coding this for a circle/oval, I can try to whip up some sample code, but for more complex geometrical shapes, I might have to do a bit more studying...

Thanks, I actually tried that exact trick with TextMeshPro but ran into some issue with the carry over. Maybe it was a tags issue or an animation issue. I can't remember. But I'll give it a try with SMP! Thanks for the fast response!

Developer

The tags for pagination should carry over from box-to-box so hopefully that still works. There should be an example script included that shows a basic pagination setup included somewhere!

Hey Kai, getting around to try this, but I can't figure out how to link the pages. Couldn't find anything in the documentation

Developer

Hey!

I forgot to mention last time, I have a script included in the sample folder named "STMPagination" that can be used to do this, or used as an example. Here's an updated version (with delegate events instead of requiring UnityEvents) so you don't have to dig through my code: https://pastebin.com/g46WEWvn

I hope this helps!

Thanks, worked like a charm!

Developer

This looks incredible!!

Okay, going very well but I've run into an issue. If I set the text on the same frame the text object was activated then it doesn't calculate the remaining text. It just assign all the text even though a bunch of it is cut off. If I set it on the first update it works fine.



Developer

To clarify, are you enabling the text gameObject or text component? There's a biiit of code that'll be changing in the next update that should finally make the two work exactly the same, but...


In some situations, when enabled, Super Text Mesh will actually take one extra frame to recalculate. It's an old fix to get around a problem with async loading. Using a manual Rebuild upon enable is probably the best option here. (You can disable auto-rebuild in the inspector to prevent it from rebuilding twice!)

Hopefully that works... if there's any further issues I'll take a deeper dive into this!

That could be the problem. I'm enabling the whole gameobject. I fixed it by calling rebuild right after setting the text.

Developer

Hey!


Would it be possible to share your polygon bounds code? Sorry this request is a year after when it was originally written.


Thanks!