I’m using TextMesh Pro to handle messages in a chat. The problem I’m running into is I’ll run the GetPreferredValues() method and the y value of the vector being returned is right the vast majority of the time, but occasionally it returns a value too low, by one line worth of height, causing the message to overflow or truncate depending on how I have it configured.
Changing fonts changes where the issue occurs. For example, if I have a sampling of 20 messages of various lengths the issue will occur on messages 2 and 7 of one font but on messages 6 and 13 on another. If I tweak the message lengths by a few characters they will be handled correctly.
My best guess as to what is happening is the font being used isn’t being taken into account or is possibly being taken into account incorrectly. I try to peek the definition of the GetPreferredValues method, but it looks like I can’t actually see the code, which from Googling I think is because it’s in a .dll.
My actual call is:
return msg.GetPreferredValues(text, game.ChatWidth, 0).y;
The text string is the content that is varying in length here, the game.ChatWidth is the width of the container these fit in to. I’m trying to get the height so I’m providing a 0 value as recommended here.
Note: I also thought it could be related to some color tags I had in there, but ruled this out by adding a bunch of tags in a separate test string and comparing the outputs. No amount of tags change the value, which seems to be correct behavior.
Has anyone else run into this and potentially have a workaround? Is my assumption on fonts way off? Happy to provide more context if it will help!