downBtn.onClick.AddListener(() =>
{
for (int i = 0; i < Container.Length; i++)
{
int nextIndex = (i + 1) % Container.Length;
if (Container[i].gameObject.activeSelf)
{
Container[i].gameObject.SetActive(false);
Container[nextIndex].gameObject.SetActive(true);
return;
}
}
});
upBtn.onClick.AddListener(() =>
{
for (int i = 0; i < Container.Length; i++)
{
int nextIndex = (i - 1 + Container.Length) % Container.Length;
if (Container[i].gameObject.activeSelf && nextIndex != 2)
{
Container[i].gameObject.SetActive(false);
Container[nextIndex].gameObject.SetActive(true);
return;
}
}
});
unity循环激活数组里的物体
最新推荐文章于 2024-07-06 10:54:52 发布