어떤 상황에서는 씬의 일부로 로드하지 않고 프로젝트에서 사용할 수 있게 하는 것이 유용합니다. 예를 들어, 게임의 모든 씬에 등장할 수 있지만 드물게 사용되는 캐릭터 또는 기타 오브젝트가 있을 수 있습니다(가령 이것은 “비밀” 기능, 오류 메시지 또는 하이스코어 알림일 수 있습니다). 또한, 초기 다운로드 시간을 단축하거나 게임 콘텐츠를 교체하기 위해 별도의 파일 또는 URL에서 에셋을 로드할 수 있습니다.
플레이어 빌드에 콘텐츠를 포함하는 데 프로젝트의 리소스 폴더 를 사용하면 빌드하는 씬과 독립적으로 필요할 때 로드할 수 있습니다.
리소스 폴더에는 빌드에 포함된 어떤 씬에서 직접 참조하지 않더라도 빌드된 Unity 플레이어에 포함된 에셋 컬렉션이 포함되어 있습니다.
리소스 폴더에 에셋을 넣으려면 Project 창 에서 새 폴더를 생성하고 폴더 이름을 “Resources”로 지정합니다. Assets 폴더 내의 여러 하위 폴더에 여러 리소스 폴더가 있을 수 있으며, 패키지에도 리스소 폴더가 포함될 수 있습니다. 그러면 프로젝트 창의 다른 폴더와 동일한 방식으로 해당 폴더에 에셋을 배치하면 됩니다. 이러한 폴더 중 하나에서 에셋을 로드할 때마다 Resources.Load()를 호출하십시오.
참고: Resources 폴더와 해당 종속성에 있는 모든 에셋은 resources.assets_라는 빌드 출력의 파일에 저장됩니다. 빌드에서 씬이 에셋을 참조하는 경우 해당 에셋은 대신 sharedAssets*.assets_ 파일로 직렬화됩니다.
Resources 폴더 에 있는 에셋만 Resources.Load()를 통해 액세스할 수 있습니다. 그러나 더 많은 에셋은 종속성이므로 resources.assets 파일에 포함될 수 있습니다. 예를 들어 Resources 폴더의 머티리얼은 Resources 폴더 외부의 텍스처를 참조할 수 있습니다. 이 경우 텍스처는 resources.assets 파일에도 포함되어 있지만 직접 로드할 수는 없습니다.
다른 씬을 로드하기 전에 Resources.Load()를 사용하여 로드된 씬 오브젝트를 삭제하려면 오브젝트에 대해 Object.Destroy()를 호출하십시오. 에셋을 해제하고 메모리를 회수하려면 Resources.UnloadUnusedAssets()를 사용하십시오.
리소스 시스템은 특히 신속한 프로토타이핑과 소규모 프로젝트에 사용하기 편리합니다. 하지만 확장성이 좋지 않아 전반적으로 이 기능의 사용을 권장하지 않습니다. 따라서 AssetBundles와 Addressables 패키지를 대안으로 권장합니다.
리소스 사용의 몇 가지 단점:
리소스 폴더는 프로젝트의 수명 내내 필요하고 업데이트가 필요하지 않으며 플랫폼이나 기기에 따라 달라지지 않는 소규모 에셋에 적합할 수 있습니다. 리소스 에셋은 에셋 번들을 통해 주요 콘텐츠를 온디맨드 방식으로 다운로드하여 게임의 최소 부트스트랩에 포함될 수 있습니다. 하지만 StreamingAssets 폴더에 있는 로컬 에셋 번들도 부트스트랩에 필요한 기능을 제공할 수 있습니다.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.