Hey! I am trying to determine when the textbox is full so that the next letter / word written won’t show. When this happens I want to execute a special part of my code.
I figured that since Unity has an overflow option there must be some way of determining it but I can’t figure it out. I’ve tried around a bit with the TextGenerator but didn’t manage to get the desired result.
This is my current relevant code;
private bool CheckIfFull(string aMessage, Text textInFocus)
{
TextGenerationSettings settings = Textbox.GetGenerationSettings(new Vector2(420, 700));
TextGenerator gen = Textbox.cachedTextGenerator;
gen.Populate(aMessage + currentWord + “wwwwww”, settings);
return (gen.lineCount > 26);
}
As you can see in this example I have currently settled with a constant of 26, but this isn’t good enough as that doesn’t fit every resolution the game can be played in. For clarification the Vector2 there is the size of the Textbox in question.
Kind regards,
Andy.