我的项目实例化了一个包含TMPro输入字段的对象。输入字段确实显示出来了,但完全无法响应;点击它或尝试在其中输入都没有任何反应。我几乎找不到关于它们的任何文档。

以下是我用来尝试让输入字段显示出来的代码:

GameObject lee = Instantiate(ads.menuWoMen, this.transform);
/*menuWoMen是承载TMP InputField的画布所在的预制体游戏对象*/
lee.transform.position = new Vector3(0, position);
string txt = mi.text;
if (position > highestText || position < 0 - highestText)
{
    txt = "";
}

lee.GetComponentInChildren<Canvas>().worldCamera = camora.GetComponent<Camera>();
lee.GetComponentInChildren<TMP_InputField>().text = txt;
lee.GetComponentInChildren<TMP_InputField>().ActivateInputField();
lee.GetComponentInChildren<TMP_InputField>().interactable = true;
lee.GetComponentInChildren<TMP_InputField>().enabled = true;