- Home /
Rich text character-by-character shows tags. How to hide them?
I have a dialog box that prints this message character-by-character: Hello <b>rat boy</b>
.
I've create a parser that checks for rich text tags and pastes them into the message (instead of printing them out, one character at a time). The problem is this: For a split second, I can see the tag in the message before it is hidden. This is what my text looks like when this happens: Hello <b>r
. And then a split-second later, it looks like this: Hello r
.
Does anyone know how to parse a rich text tag before it's visible in a message?
I wrote a rich text parser like this once, but I didn't have the problem that you're talking about. Does your parser only work on the bold tag? Are you trying to detect new tags by looking for the left carat? Are you adding the closing tag at the same time that you're adding the opening tag?
I would have to see some code to figure out what's going wrong. It sounds kind of like this is being done in a loop with a small delay between iterations and your closing tag is being added on a later iteration than you open tag, giving the opening tag enough time to be displayed for a short period.
Found the problem. I needed to add the closing tag after the last rendered character. http://answers.unity3d.com/questions/894876/rich-text-issue.html
I thought rich text tags were like HT$$anonymous$$L tags, but they're not. You have to have both the opening and closing tag to apply a style to the content within.
Answer by majecty · Nov 18, 2018 at 01:45 AM
I created a helpful library for this issue.
You can get substring of rich text just a function.
var richText = "<color=blue>blue</color>black";
richText.RichTextSubString(3); // <color=blue>blu</color>
richText.RichTextSubString(6); // <color=blue>blue</color>bl
You can find it in Github.
Answer by SamuelGoldenbaum · Nov 18, 2018 at 02:33 AM
Clearly it’s waiting for the closing tag. You would need to write some code to loop through the characters and output it if no < is found, if the current char is < then use reg ex to match what’s inside the opening <> and place a temp closing tag after each character iteration following until you get to next < .
doable but painful few hours of work.