Plants 폴더(Scriptable Object) - Corn 복제: Super Corn

스크린샷 2023-10-10 191133.png

PlantItem 복제 - Plant: Super Corn

스크린샷 2023-10-10 191529.png

새로운 행 추가 확인: 이런 방식으로 새로운 식물 추가 가능

스크린샷 2023-10-10 191637.png

public class StoreManager : MonoBehaviour
{
    public GameObject plantItem;

    private void Awake()
    {
        // Assets/Resources/Plants (경로 혼동 주의!)
        var loadPlants = Resources.LoadAll("Plants", typeof(PlantObject));
        foreach (var plant in loadPlants)
        {
            PlantItem newPlant = Instantiate(plantItem, transform).GetComponent<PlantItem>();
            newPlant.plant = (PlantObject)plant;    // PlantItem.cs에서 선언한 plant로
        }
    }
}

Inspector 창에서 PlantStore 하위 오브젝트인 PlantItem 프리팹 4개 삭제

StoreManager 스크립트 추가 - Plant Item: PlantItem 프리팹 추가

스크린샷 2023-10-10 194003.png

Resources 폴더 생성