problem with TMP

More
7 years 11 months ago #1411 by qiankanglai
problem with TMP was created by qiankanglai
Unity 5.3.4
I2 2.6.5
TextMeshPro Release 0.1.54 Beta 2


I've encountered the following problem when Localize a very long sentence:
IndexOutOfRangeException: Array index is out of range.
TMPro.TMP_Text.SetText (System.String text, Single arg0, Single arg1, Single arg2) (at Assets/TextMesh Pro/Scripts/TMP_Text.cs:1308)
TMPro.TMP_Text.SetText (System.String text, Single arg0) (at Assets/TextMesh Pro/Scripts/TMP_Text.cs:1229)
I2.Loc.Localize.DoLocalize_TMPUGUILabel (System.String MainTranslation, System.String SecondaryTranslation) (at Assets/I2/Localization/Scripts/Targets/LocalizeTextMeshPro.cs:139)
I2.Loc.Localize.OnLocalize (Boolean Force) (at Assets/I2/Localization/Scripts/Localize.cs:169)
I2.Loc.Localize.Awake () (at Assets/I2/Localization/Scripts/Localize.cs:92)
UnityEngine.Object:Instantiate(GameObject)

My question is: why the second line is needed in LocalizeTextMeshPro.cs?
mTarget_TMPUGUILabel.text = MainTranslation;
mTarget_TMPUGUILabel.SetText(MainTranslation, 0);
If you pass a long text in SetText (length > 255), TMP will raise error :ohmy:

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago - 7 years 11 months ago #1412 by Frank
Replied by Frank on topic problem with TMP
Hi,
Problem is that I2L has to support several versions of TMPro.
In some previous versions, SetText was the only way to make sure that the label text was updated properly after setting the text. However in other versions that function was broken and .text was the one that worked.

So, as a workaround, I added both.

You can safely delete the .SetText and just let the .text (as they are interchangeable).

I will also email Stephan so that he knows about this issue.

Thanks,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
Last edit: 7 years 11 months ago by Frank.

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago #1413 by qiankanglai
Replied by qiankanglai on topic problem with TMP
Thanks for the quick reply!

I think maybe some #define is needed for this. And these two API are not equally the same.
Currently I'm commenting out the second one and it works well B)

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago - 7 years 11 months ago #1472 by Caligari
Replied by Caligari on topic problem with TMP
Just adding that I am seeing the same issue, and have come up with the same fix. I'd also hope that a #define might remove the need for this change (which I'm sure I'll forget to apply when I update at some point).

Loving the localization, though, I must say! Thanks for the hard, and excellent, work!
Last edit: 7 years 11 months ago by Caligari. Reason: fix typo

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago #1473 by Frank
Replied by Frank on topic problem with TMP
Hi,
In version 2.6.6a3 (currently in the beta folder), I dropped support for the old TMPro versions that had the .text property broken.
So, I commented out the SetText line and now it should work fine.

Hope that helps!
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The following user(s) said Thank You: Caligari

Please Log in or Create an account to join the conversation.

Time to create page: 0.144 seconds
Template by JoomlaShine