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.

posted @ 2018-10-15 20:12  朋丶Peng  阅读(2741)  评论(0编辑  收藏  举报