34 lines
643 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SetFalse : MonoBehaviour
{
public Transform[] hiddenChildren;
[ContextMenu("隐藏")]
// Start is called before the first frame update
void Setttt()
{
HideChildrenRecursively(transform);
}
void Start()
{
}
void HideChildrenRecursively(Transform parent)
{
foreach (Transform child in parent)
{
// 隐藏当前子物体
child.gameObject.SetActive(false);
// 递归调用以处理子物体的子物体
HideChildrenRecursively(child);
}
}
}