• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    해결됨

return Object.Instantiate(prefab, parent); 여기서 값이 Null로 바뀌어요

23.12.22 12:22 작성 23.12.22 12:28 수정 조회수 241

0

 

ResourceManager 스크립트 코드 중 일부입니다.

 

public GameObject Instantiate(string path, Transform parent = null)

{

GameObject prefab = Load<GameObject>($"Prefabs/{path}");

if (prefab = null)

{

Debug.Log($"Failed to load prefab : {path}");

return null;

}

return Object.Instantiate(prefab, parent);

}

 

여기서 prefab에 로드로 경로 잘 찾아서 오브젝트가 잘 들어가는데요

return Object.Instantiate(prefab, parent);

이 부분에서

아래의 오류가 뜹니다 ㅠㅠ 어딜 다시 봐야할까요??

 

System.ArgumentException: The Object you want to instantiate is null.

at UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) [0x00009] in <30adf90198bc4c4b83910c6fb1877998>:0

답변 2

·

답변을 작성해보세요.

0

image

0

혹시 prefab == null 부분에서

에서 = 을 하신걸까요?

ㅋㅋ.... 맞아요.. 3시간 날릴 만큼 안보였네요 감사합니다 하핫