Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Nested color tag don't work

A topic by miksol created Jul 14, 2020 Views: 148 Replies: 2
Viewing posts 1 to 2
(2 edits)

Hi!   Why don't nested color tags work?    for example : <c=#ff00ffff>hello <c=#00ff00ff>wonderful </c> world</c>

 in standard TextMesh and UItext it works <color=#ff00ffff>hello <color=#00ff00ff>wonderful </color> world</color>

in our project there are large texts about 10000 chars where a large section is highlighted in color and it is necessary to highlight the numbers of subitems in a different color, now we are doing a simple replacement of numbers with numbers with color tags, but with STM it don't work

Is it possible to implement it?
Thanks!

Developer

Hey!

Nested colour tags (or any tags of the same type, for that matter) are not part of STM... When I first started out programming it was because I didn't know how to do it, but now it's because I believe it's an easier pattern to use. 

For example... lets say you want to type the string <c=red>R<c=orange>A<c=yellow>I<c=green>N<c=blue>B<c=violet>O<c=pink>W

To get back to normal text, in STM you'd just have to do </c>. But with nested tags, it's </c></c></c></c></c></c></c>. Another way to think about it is... every <c=x> tag essentially also works as an invisible </c> tag! This also makes it easier to pragmatically type text, since you don't have to remember how many layers of text formatting you're currently on. In addition to this reason, there's a lot of STM users by this point, so changing something like this would cause a lot of problems for a lot of people... I have considered it though.


For your situation, I'd recommend... When finishing the subitem highlighting, use <c=prevcolour> instead of </c>! Or if you are pragmatically generating the text, you can do a replacement script (or STM's pre-parsing loop!) to adjust your string before it's sent to STM. I have some sample code included for parsing custom tags, and I think I could adapt this so it formats numbers instead of tags in the same way.

So... the short answer is... Nested tags don't work because lots of people are using the current tag system, but there's other workarounds you can do to have a smooth typing experience!

If you need any additional programming help, please let me know.

Оk thanks for the answer! I understand