1. 程式人生 > >unity中如何獲取所有子物體的元件

unity中如何獲取所有子物體的元件


    public GameObject[] obj;

    void Awake()
    {
   
        for (int i = 0; i < obj.Length; i++)
        {
            for (int j = 0; j < obj[i].transform.childCount;j++ )
            {
                print("obj[i].transform.childCount=" + Enemy_Path[i].transform.childCount);
                obj[i].transform.GetChild(j).GetComponent<"想要獲取的元件
">().enabled = false;
            }