我需要通过比较圆柱和孔的变换位置来检查孔是空的还是空的。请注意,我不能简单地做else if (cylpos != holpos)
,因为我需要那样做。看来if (!fullHoles.Contains(hole))
并没有按照我的意愿工作。
foreach (GameObject hole in Holes)
{
holpos = hole.transform.position;
foreach (GameObject cylinder in Cylinders)
{
cylpos = cylinder.transform.position;
if (cylpos == holpos)
{
fullHoles.Add(hole);
}
}
if (!fullHoles.Contains(hole))
{
emptyHoles.Add(hole);
Debug.Log(hole);
}
}
感谢您的帮助!