Changing textbox height dynamically.

What up.

I’m instantiating a textbox gameobject.
Then filling it up with text.

Any way to make the textbox height dynamically change?

GameObject reply1 = Instantiate(replyText, transform.position, transform.rotation);
reply1.transform.SetParent(textArea.transform, false);
Text reply1text = reply1.GetComponent();
reply1text.text = gameRounds[roundCount].reply[0];

The width is fine, don’t need to change it.

I just made a script.

// calculate the reply length
int replyLength = reply1text.text.Length;
RectTransform replySize = (RectTransform)reply1.transform;
float width = replySize.rect.width;
float height = replySize.rect.height;

if(replyLength>50)
{
replySize.sizeDelta = new Vector2(width, 150f);
}