2017-09-03 170 views
0

怎麼了。Unity UI文本框動態高度。我如何根據文字量擴大它?

我正在實例化一個文本框gameobject。 然後用文字填滿。

任何使文本框高度動態變化的方法?

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

寬度很好,不需要改變它。

回答

1

您可以將文本框的垂直溢出設置更改爲溢出。它會根據文本內容自動增加文本框的高度。
enter image description here

相關問題