【发布时间】:2019-12-27 06:22:04
【问题描述】:
我在运行时通过脚本创建了一组预制件。它们保存在一个名为 newObj 的数组中。每个都有一些文本 UI 和一些按钮,我使用 GetComponentsInChildren 检索它们。当用户单击预制件中的第一个按钮时,我想运行一个函数来更改按钮的文本并突出显示该按钮。
一切正常,只是按钮没有突出显示。
public void SelectPlayer(int rowSelected)
{
var buttons = newObj[rowSelected].GetComponentsInChildren<Button>();
var texts = newObj[rowSelected].GetComponentsInChildren<Text>();
texts[0].text = "1";
buttons[0].Select();
buttons[0].OnDeselect(null);
}
【问题讨论】: