해당 함수를 사용하면 자식 오브젝트 뿐만 아니라 본인 오브젝트에 포함된 컴포넌트도 가져옵니다. 따라서 사용시에 주의해서 사용해야 합니다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/* Smf : Stat Modifier Feature */
public class Smf : MonoBehaviour
{
public string itemName;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Consume : MonoBehaviour
{
public Smf[] smfList;
void Start()
{
smfList = gameObject.GetComponentsInChildren<Smf>();
}
}
'프로그래밍 > 유니티' 카테고리의 다른 글
[유니티] Scriptable Object 알아보기 (0) | 2022.04.21 |
---|---|
[유니티] 인벤토리 시스템 제작 (0) | 2022.03.23 |
[유니티] SerializeField 알아보기 (0) | 2021.02.28 |
[유니티] Scriptable Object 알아보기 (1) | 2021.01.03 |
[유니티] Editor 관련 자주 사용하는 변수 및 함수 정리 (0) | 2020.12.10 |