【发布时间】:2020-06-14 10:58:37
【问题描述】:
启用/禁用复选框时的最佳监听方法(在 Unity 编辑器中)?
我想在运行/播放场景时启用和禁用
也许可以切换一次,当我再次单击时编辑器可能会等待? 我不需要每个更新扫描列表..
我的代码:
void Update () {
checkboxStatus(visibleLocations, locationsList);
}
public void checkboxStatus(bool checkboxEnabled, List<GameObject> list)
{
if (list.Count > 0)
{
foreach (var item in list)
{
if (checkboxEnabled)
{
item.GetComponentInChildren<MeshRenderer>().enabled = true;
}
else
{
item.GetComponentInChildren<MeshRenderer>().enabled = false;
}
}
}
}
【问题讨论】: