我正在尝试输出甘特图,但我使用三个for循环。我尝试使用它,但它破坏了我的程序。它可以用一个for循环? (我开始,你怎么看,我有丑陋的代码)
int numChildren = gameObject.transform.childCount;
for (int i = 0; i<numChildren; i++)
{
for (int a = i+1; a<numChildren; a++)
{
while (gameObject.transform.GetChild(a).GetComponentInChildren<Collider>().bounds.Intersects
(gameObject.transform.GetChild(i).GetComponentInChildren<Collider>().bounds))
{
// print
Debug.Log("Bounds intersecting " + i + ":" + a);
// moving
gameObject.transform.GetChild(a).GetComponentInChildren<Transform>()
.transform.Translate(Vector3.right * 1f, Space.World);
}
}
}