Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Inline tables

A topic by Neon Specter created 18 days ago Views: 30 Replies: 2
Viewing posts 1 to 3

I'm trying to create a stats table with labels and values.  Short example:

"Damage:      A

Defense:       B

Complexity:  Moderate"

I want all the values to line up vertically.  I've tried playing around with monospace and gotten close, but it messes up the character spacing within words.  Justified alignment also gets close, but pushes text too far to the right and also only aligns the last letter of each word, instead of the first.

I'd like to avoid using multiple text fields as that greatly complicates positioning with other variable length text.  Is there anything else I can use to achieve this?

Developer (1 edit)

Does using a unity Grid Layout and multiple STM object complicate positioning too much? That would be fine for text that's spaced evenly, but I think I've seen a modified grid layout component somewhere that can use the size of what's inside for each row/column. (Together with contentsizefitter & STM that might be a solution)

Anyway, simpler second idea I have: indents and carriage returns!


A string like this will work:

"Damage:<indent=5><u=000D>A</indent>

Defense:<indent=5><u=000D>B</indent>

Complexity:<indent=5><u=000D>Moderate</indent>"




...with "5" being the width between columns (will need to be bigger for bigger text, etc), and <u=000D> being equivalent to "/r", the carriage return, which goes back to the start of a line without dropping down. (and setting the indent changes where the start of the line is)


I hope this helps!

That works perfectly. Thank you.