//子物体的隐藏
foreach(Transform child in this.GetComponent<Transform>())
{
if (child.name == "要隐藏的名字")
{
if (child.gameObject.activeSelf == false)
{
child.gameObject.SetActive(false);
}
else
{
child.gameObject.SetActive(true);
}
}
//所有子物体出现
foreach(Transform child in this.GetComponentsInChildren<Transform>())
{
child.gameObject.SetActive(true);
}
//某个子物体
Transform[] transform = this.GetComponentsInChildren<Transform>();
for(int i = 0; i < transform.Length; i++)
{
transform[i].gameObject.SetActive(true);
}