Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some TMPro tags are not stripped, resulting in exceptions #24

Closed
edwardrowe opened this issue Apr 24, 2019 · 6 comments
Closed

Some TMPro tags are not stripped, resulting in exceptions #24

edwardrowe opened this issue Apr 24, 2019 · 6 comments

Comments

@edwardrowe
Copy link

We need to strip all native tags when parsing the text, or else it will calculate the wrong number of characters to print and results in an ArgumentException.

Repro:

  1. Add a <style> tag to text
  2. Print it
  3. Observe ArgumentException

To fix, we either need to add all missing "Unity" tags to the parser, or calculate characters to print based on the visible text. For now the easiest fix is to include all missing tags. Ex:

style
link

Another issue that could come up is you can use color like "<#FFFFFF>" instead of <color=#FFFF>. If that results in this same issue, we may want to look at solution that examines the visible text.

@edwardrowe edwardrowe added the bug label Apr 24, 2019
@edwardrowe edwardrowe changed the title Not all TMPro tags are stripped Some TMPro tags are not stripped, resulting in exceptions Apr 24, 2019
@edwardrowe
Copy link
Author

For a full list of tags, see http://digitalnativestudios.com/textmeshpro/docs/rich-text/

@jushii
Copy link

jushii commented Sep 17, 2019

https://gist.github.com/jushii/afd171d1234c0541af3cb97e6e7b2a64

This should fix most of the exceptions and make the tags work. I also added a few missing ones that are not in the TMPro documentation (e.g. gradient)

@edwardrowe
Copy link
Author

Awesome, thanks for the list!

@nguyentrong101094
Copy link

nguyentrong101094 commented Jun 23, 2020

Currently, I get an exception when trying to type out this string:
"You can use Diamonds <sprite="diamond" index=0> to buy more."
I'm using version 2.2

So to fix this, I have to edit the class TextTagParser and change the UnityTagTypes field to the one written by @jushii? Why not include it in the release?

@edwardrowe
Copy link
Author

edwardrowe commented Jun 23, 2020

These should absolutely be included. There's no reason I haven't - just haven't had time to update this repository much (though it's on the top of my list for my side projects).

You are correct - changing out this line to use @jushii's gist should work:

private static readonly string[] UnityTagTypes = new string[] { "b", "i", "size", "color", "style" };

In theory I'd also like to add these tags into the tests for tag parsing:
https://github.com/redbluegames/unity-text-typer/blob/master/Assets/RedBlueGames/TextTyper/Tests/Editor/TextTagParserTests.cs

@edwardrowe
Copy link
Author

edwardrowe commented Jun 28, 2020

Should be fixed in release 2.3 https://github.com/redbluegames/unity-text-typer/releases/tag/v2.3

Thanks for the help, @jushii and @nguyentrong101094!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants