백지부터 시작하는 이세계 코딩 생활
GetComponentInChildren, GetComponentsInChildren 본문
백지부터 시작하는 이세계 유니티 생활 since 2020
GetComponentInChildren, GetComponentsInChildren
조아덕 2020. 11. 18. 16:46함수이름에서 짐작할 수 있듯이, 특정 컴포넌트 ( Component ) 를 반환받기 위해서, 찾아오기 위해서 사용한다.
GetComponentInChildren
특정 컴포넌트의 하위(자식)객체 중 가장 선두에 존재하는 컴포넌트를 반환 시킨다.
GetComponentsInChildren
특정 컴포넌트의 하위(자식)객체의 모두를 반환시킨다. 이때, 반환은 Array ( 배열 ) 형태로 반환된다.
Component
GaemObject 의 기능적인 조각들을 의미한다.
Components는 오브젝트(objects)와 동작(behaviours)에 관한 너트와 볼트로 볼 수 있습니다.
GameObject는 다양한 컴포넌트들에 대한 컨테이너입니다. 기본적으로, 모든 GameObject는 자동으로 Transform 컴포넌트가 포함되어 있습니다. 이것은 Transform 컴포넌트에 의해 GameObject가 어디에 위치하고 있는지, 얼마나 회전하고 있는지, 어느 정도의 크기인지 결정되기 때문입니다. Transform 컴포넌트가 없다면 GameObject는 월드에 있을 곳이 없어져 버립니다
Ref. docs.unity3d.com/kr/530/Manual/UsingComponents.html
private void Awake()
{
anim = GetComponentInChildren<Animator>();
rb = GetComponent<Rigidbody>();
}
Ref.
'백지부터 시작하는 이세계 유니티 생활 since 2020' 카테고리의 다른 글
Quaternion, LookRotation, Normalize (0) | 2020.11.18 |
---|---|
Rotation, Rotate (0) | 2020.11.18 |
Awake -- Script 및 함수들 작동 우선순위 (0) | 2020.11.18 |
Coroutine, IEnumerator, yield return (0) | 2020.11.17 |
parameter, argument (0) | 2020.11.17 |
Comments