Unity GetComponentsInChildren<T>(true);

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GetComponent : MonoBehaviour
{
    public Transform[] transforms;

    void Start()
    {
        transforms = GetComponentsInChildren<Transform>(true);
    }
}
GetComponentsInChildren<Transform>(true);//游戏对象下的子物体激活的没激活的都会被拿到,包括游戏对象本身
GetComponentsInChildren<Transform>(false);//游戏对象下的子物体激活的会被拿到,包括游戏对象本身;没激活的不会被拿到
另外,()不写的活默认为false.

原文地址:https://www.cnblogs.com/Peng18233754457/p/9794337.html