[정보] Unity Resources.Load 스크립트상에서 유니티 Resources 폴더에 있는 데이터 사용하기!
https://docs.unity3d.com/kr/530/ScriptReference/Resources.Load.html
Unity - 스크립팅 API: Resources.Load
Returns the asset at path if it can be found otherwise returns null. Only objects of type will be returned if this parameter is supplied. /path/는 프로젝트의 애셋 Assets 폴더에 내에 Resources 폴더의 상대경로로, 확장자는 생략되
docs.unity3d.com
https://docs.unity3d.com/ScriptReference/Resources.Load.html
Unity - Scripting API: Resources.Load
This method returns the asset at path if it can be found, otherwise it returns null. Note that the path is case insensitive and must not contain a file extension. All asset names and paths in Unity use forward slashes, so using backslashes in the path will
docs.unity3d.com
위 도큐먼트들을 참고했는데 아래것이 더 최신 도큐먼트이다.
빨간 원이 쳐진 부분을 부분을 보면 GameObject 형태의 프리팹을 로드하기 위해 두 가지 방식을 사용한것을 볼 수 있다.
1. Resources.Load("파일경로", typeof(GameObject)) as GameObject
2. Resources.Load<GameObject>("파일경로")
둘 다 문제없이 동작하지만, 두 번째 방법이 좀 더 최근의 도큐먼트에서 추천하는 방법이기도 하고 보기에도 간결하기 때문에 이 방법을 추천한다.
인자로 전달되는 파일 경로는 Resources 폴더 바로 아래 경로부터 적어주면 되는데, 파일의 확장자는 적지 말고 파일 이름까지만 적어주면 된다!