Study/Unity
오브젝트를 배열로 찾아오기 - FindGameObjectsWithTag
치피킨자
2019. 8. 12. 15:16
https://docs.unity3d.com/kr/530/ScriptReference/GameObject.FindGameObjectsWithTag.html
Unity - 스크립팅 API: GameObject.FindGameObjectsWithTag
Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. 닫기
docs.unity3d.com
태그된 활성 게임오브젝트 리스트를 반환합니다. 게임오브젝트를 찾지 못햇다면, 빈 배열이 반환됩니다.
태그는 사용전에 tag manager에 선언 되어져야 합니다. 태그가 존재하지 않거나 빈 문자열 이나 null이 태그로 전달되면 UnityException을 발생시킬 것입니다.
게임 상의 같은 태그를 가진 오브젝트를 배열로 가져오고 싶을 때 사용.
GameObject[] objArr;
void Start () {
objArr = GameObject.FindGameObjectsWithTag("Tag");
}