I ran into some interesting problems when implementing this. Say you have text with tags in them that you have to parse, this text also need to be broken up into lines manually, what would you do first? Splitting the text up for the colors first leaves you with chunks that may or may not fit on a single line, having to split up these parts again seems like a lot of work. The second approach is breaking the text up by lines first, but this time you run into the problem that the tags are still there so you'll end up with lines not filling the entire width. Oh noes!
I went for the second option, but on determining where to break the lines I keep the tags in mind. That means that every time I need a length or offset into a string I manually count said length or offset and ignore tags in the process.
Another thing was that ImGui is (obviously) an immediate mode UI library, which has it's drawbacks. I would have to parse tags and break up lines on every frame, which might not be a problem for the length of my game on modern day computers, but it felt wrong to keep it like that. So I implemented some retention for my multi-line colored text, I only have to parse tags and break lines once. Okay maybe that's not exactly true... once per window resize.
That's all for now, of to some gameplay programming!
Screenshot:
Using RichText enabled Unity engine for the past one year, it's easy to forget just how much trouble it is to get colored text in a any given body of text. Gratz on achieving this and having to deal with what many take for granted!