해당 함수를 사용하면 자식 오브젝트 뿐만 아니라 본인 오브젝트에 포함된 컴포넌트도 가져옵니다. 따라서 사용시에 주의해서 사용해야 합니다.

 

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>();
    }
}

 

블로그 이미지

NIA1995

,