for (int i = 0; i < rewardGrid.transform.childCount; i++) { GameObject it = rewardGrid.transform.GetChild(i).gameObject; it.transform.parent = null; Destroy ( it ); }
或者
while (grid.transform.childCount > 0) { DestroyImmediate(grid.transform.GetChild(0).gameObject); }
时间: 2024-10-13 00:24:44