TMP_InputField 理解

一、输入框激活问题

public void ActivateInputField(); //激活输入框

public void DeactivateInputField(bool clearSelection = false);//灭活输入框 ,谁能告诉我 clearSelection 是什么用处?

先激活再灭活的话,要隔一帧

 

二、输入框自适应高度

TMP_InputField input;

input.textComponent.textInfo.lineCount //文字行数

input.textComponent.preferredHeight //最佳高度

lineCount 和 preferredHeight 配合起来,可以实现,输入框随着输入文字数量的变化而改变高度。

用ContentSizeFitter 也可以,但是不能限制最大高度(会报错 Trying to add Caret (TMPro.TMP_SelectionCaret) for graphic rebuild while we.....)。

 

posted @ 2021-08-24 17:10  zerozabuu  阅读(1039)  评论(0编辑  收藏  举报