the component textmeshpro UGUI is showing the correct text, but i cant see it in the game.
2.- im using is TextTruncated to activate other objects in scene and change the margin and local position of my textmeshpro object and using ForceMeshUpdate, to see the changes, which are not happening, so textTrucated stays in false.
There could be any number of things affecting this including the use of isTextTruncated which is readonly where it should not be changed. This is used by TMP when parsing the text to deal with things like ellipsis, truncation and other things and would affect updates of the text object. You should be able to do all the changes you describe with regards to margin position and all without touching isTextTruncated.
Second, try using the plain .text property instead of SetText to see if you get the same behavior?
Hi thanks for your reply!!
I’ve tried the .text property and SetText(); none of them seems to change my text as i wanted.
were not changing isTextTruncated, we’re just checking if it gets truncated for something to happen…
i just think its not updating the text since it gets shown in the inspector, what do you think?
I would have to get a repro of this to take a closer look. If you can provide me with a repro, make sure that you do so privately via some link provided to me in a Private Message (PM).
I just encountered this same issue. I am only using the .text value to update the string. I have “Wrapping & Overflow” disabled. Disabling “Auto Size” for Font Size was the only way I could get the display to update.
This is likely something else so I will need more details.
Unity in any public fields or in the Inspector escapes control characters like “\n” which results in these being converted into a string literal or a "" + “n” instead of the linefeed which is char (10).
I suspect the issue you are having is potentially related to this but like I said I will need more. Do you have some example script that reproduces the behavior or can you provide a Repro project?
I also encountered this issue, after som testing it seems to have something to do with an animator animating the alpha of the text. I was however not able to replicate the issue on another object. I finally rolled back to the latest commit and have not encountered it since.
When testing I also noticed that when making changes while paused and then unpausing the changes were applied as expected but not in realtime. Very strange issue.
I’ve got two types of enemies set up, ones that move and ones that don’t. They both share the same Animator Controller, so the animations being called to alter the text is identical. The animation simply moves the alpha up or down depending on if I’m showing or hiding the enemies name.
On the enemies that move, this works without any issue. On the stationary enemy the text is never visible, despite being in the correct animation and the alpha having been moved up. If I pause the game and alter the text in editor, by for example deleting one letter then the text appears.
I’m assuming that because one enemy is moving they are always having to redraw the text where as the stationary one must not be noticing a change to the asset. It would be good to get a fix for this.
Unless a property of the text object changes, moving the object around should not trigger a regeneration. If the scale of the text object changes, this would trigger a regeneration as the SDF scale needs to be updated.
When a text object is affected by an animation, update of the text object is driven by the OnDidApplyAnimationProperties() callback in the case. For the legacy animation system which doesn’t have a callback, you have to set the “isUsingLegacyAnimationComponent” property to true.
I think the difference in behavior is related to this but I would need some repro scene or project to figure out exactly why.
ForceMeshUpdate() is forcing the object to be regenerated so if the object wasn’t aware that it should be updates because of changes coming from the legacy animation, that would work.
I use 2DToolkit in my project, and I’m in the process of replacing all instances of tk2dTextMesh with TextMesh Pro.
Things were going relatively smoothly, until I needed to change Wrapping & Overflow in one TMP instance from the default Overflow to Truncate. I found the following behaviour:
When I duplicate the GameObject with the TMP component, the clone displays no text in the scene, even though the Text Input Box contains text. Additionally, although the original GameObject displays text properly in the scene, after I unload and reload the scene, it too, does not display in the scene the text in its Text Input Box.
Switching back to Overflow restores visibility of the existing text, but if I switch to Truncate again, and type extra characters in the Text Input Box, the extra characters are not displayed in the scene. However, after adding enough (or too many) characters, much beyond what would cause a truncation, all characters disappear from the scene. They reappear after I switch to Overflow.
While in Overflow, if too many characters are added, and characters do get overflown to the next line, switching to Truncate does nothing. In fact, switching to any other Wrapping & Overflow setting has not effect, and TMP becomes unresponsive, as far as displaying text properly in the scene is concerned. Setting Overflow again restores functionality.
I created a new empty project and imported TextMesh Pro and 2DToolkit. I created the same font asset as in my project, replaced the default camera with tk2dCamera, and used these for testing. There was no problem! Wrapping & Overflow functionality was correct with all settings.
So, it must be something specific to my project, but I’m at a loss of what to do to fix it.
I use Unity 2017.2.1f1 and TextMesh Pro 1.2.2
Any ideas?
EDIT: I created a repro case - Just a GameObject with TMP component and Main Camera in the scene, and only TMP and the custom font asset in the Project Assets. I reproduced all of the above behaviour.