부모 객체에만 태그를 지정하고 자식들을 가져오게 할 수도 있다.

 

ex)

        GameObject parent = GameObject.FindGameObjectWithTag("Path");

        // 해당 코드로 parent.transform 에서 Transform[] 자식 객체들을 리턴한다는걸 유추할 수 있음.
        foreach (Transform child in parent.transform) 
        {

            // 그럼 거기서 이제 하나하나 필요한거 뽑아오면 된다
            path.Add(child.GetComponent<Waypoint>());
        }

 

+ Recent posts