- Home /
Cached Text Generators characterCountVisible returning incorrect values
I'll start off by saying there's a good chance I'm misunderstanding something here, so apologies in advance if I missed something.
The way I understand it, if I have a Text element on screen and I want to return the number of characters that Unity believes are being displayed (before being truncated) I can find that character count via:
textComponentReference.cachedTextGenerator.characterCountVisible
It stands to reason that if I had the string length (easy to find), I could compare the two to figure out if something is getting truncated, and take appropriate actions from there...
However, I'm noticing that characterCountVisible is returning values that I'm not understanding - for example:
Text: Something
As seen on-screen: Somethi
Length: 9 (Correct)
characterCountVisible: 6 (WAT?)
I would really like to know what is going on here, so if someone could help me understand how characterCountVisible works, that'd be great. Because I'm clearly not picking up what Unity is throwing down.
Cheers!
Answer by maxizrin · Dec 10, 2015 at 05:12 PM
Maybe it's not updated?
Try "Canvas.ForceUpdateCanvases();" after assigning the text, but before checking the visible characters count.