<span style="font-size:18px;">for (int i = 0; i < gameObject.transform.childCount; i++)
{
if (</span><span style="font-family: Arial, Helvetica, sans-serif; font-size: 18px;">gameObject</span><span style="font-family: Arial, Helvetica, sans-serif;">.transform.GetChild(i).gameObject.GetComponent<>().)</span><span style="font-size:18px;">
{
gameObject.transform.GetChild(i).gameObject.GetComponent<>().;
}
}</span></pre><pre name="code" class="csharp">获取然后删除for (int i = tr.childCount - 1; i >= 0; i--) {
Destroy(tr.GetChild(i).gameObject);
}或者存到一个列表里
List lst = new List;
foreach (Transform child in transform)
{
lst.Add(child);
Debug.Log(child.gameObject.name);
}以上就是获取子物体的一些方法,非常简单
本文介绍了如何在游戏开发中获取并操作子物体,包括获取、删除和存储子物体的方法,详细步骤清晰易懂。

5820

被折叠的 条评论
为什么被折叠?



