access all child
[유니티] 모든 자식들 접근하기
[유니티] 모든 자식들 접근하기
2020.02.26유니티에서 간단하게 모든 자식들 접근하기 1. 선택한 게임 오브젝트 바로 아래에 있는 자식만 iterate하고 싶은 경우 foreach(Transform child in transform) { Debug.Log(child.name); } 2. 선택한 게임 오브젝트 아래에 있는 모든 자식을 iterate하고 싶은 경우 Transform[] allChildren = GetComponentsInChildren(); foreach(Transform child in allChildren) { // 자기 자신의 경우엔 무시 // (게임오브젝트명이 다 다르다고 가정했을 때 통하는 코드) if(child.name == transform.name) return; Debug.Log(child.name); } GetComp..