Addressable Assets System
1. 필요성
UNITY는 흔히 Resources 폴더를 사용하거나, 이를 보완하기 위해 에셋 번들을 많이 사용하였다.
하지만 2개다 한계점을 갖고 있었고 유니티에서는 이 2개의 장점을 합쳐 Addressable Assets System을 만들고 소개하였다.
Resources의 단점
Asset Bundle의 단점
리소스 폴더의 접근에 직관적이다는 장점과 에셋번들의 장점을 합쳐 Addressable Assets System을 만들었다.
2. Addressable Assets System 란 무엇인가?
- Address 에 할당된 Asset이다.
Asset에 주소를 부여하여 필요시에 주소를 통해 접근하여 Asset의 필요한 부분만 갖고 올 수 있다.
Address를 이용하기 때문에 Asset위치에 상관하지 않고 참조 가능하다.
-Addressable Assets System
Adress를 이용하여 Asset의 관리, 로딩, 빌드가 통합된 시스템
에드레서블 에셋 + 리소스 매니저 + 스크립터블 빌드 파이프 라인 -> 패키지 매니저로 제공.
3. 어드레서블 에셋 시스템 동작 방식
위의 그림은 어드레서블 에셋 시스템의 과정을 간단히 보여주는 그림이다.
어드레서블 에셋은 기본적으로 2개의 패키지로 구성되어 있다.
-Addressable Assets package (primary package)
-Scriptable Build Pipeline package (dependency)
먼저 Sriptable Build Pipeline packeage는 Unity Build 콘텐츠를 관리해주는 역할을 한다. 기존의 Assets Bundle의 버전 정보를 저장하고, 사전 정의된 AssetsBundle 빌드를 확인하고 Build시간을 단축하고 변경된 AssetsBundle을 개선해주어 유연성을 제공한다.
Addressable Assets package은 이러한 실질적으로 사용자가 사용하는 일련의 작업을 담당해주는 패키지이다.
위의 그림을 보면 초기 작업 과정에서 content catalog를 작성하는데, 사용자는 AssetBudle에 넣을 prefab을 저장하며, 접근할 Address를 지정해준다. 이를 Bulid하면 Sriptable Build Pipeline packeage에서 버전 정보를 저장하여ResouceManger에 하나의 Provider를 생성한다.
이렇게 저장된 Provider를 사용자는 코드로 저장된 Address를 Addressable Assets package에 요청하고 패키지에서 ResourceManager에 정보값을 통해 해당되는 Provider를 접근하여 로드를 시켜준다.
가장 궁금했던 부분이 외부 저장 데이터에 대한 플로우였는데, 그 부분에 대해 기록해둔다.
Content update workflow | Addressables | 1.16.19
Content update workflow Addressables provides a content update workflow intended for games that will dynamically be downloading content from a CDN. In this situation, a player (app, exe, apk, etc.) is built and deployed (such as through the Android app sto
docs.unity3d.com
Addressables uses a content catalog to map an address to each Asset, specifying where and how to load it. In order to provide your app with the ability to modify that mapping, your original app must be aware of an online copy of this catalog. To set that up, enable the Build Remote Catalog setting on the AddressableAssetSettings Inspector. This ensures that a copy of the catalog gets built to and loaded from the specified paths. This load path cannot change once your app has shipped. The content update process creates a new version of the catalog (with the same file name) to overwrite the file at the previously specified load path.
밑 줄 그어진 부분에 대해 보면 '카탈로그의 복사본이 지정된 경로에 빌드되고 로드됩니다.' 라고 되어있다. 즉 지정된 외부 데이터에 접근하여 버전을 확인하고 없을 경우, 혹은 버전이 다른 경우 카탈로그의 복사본을 지정한 경로에 빌드 되는 것을 알 수 있다. 자동으로 버전을 확인해 주고 업데이트해주는 기능을 제공하고 있는 것이다.
4. 구현
구현은 많은 레퍼런스가 있기 때문에 굉장히 쉽게 구현할 수 있었다.
그 중 추천하는 영상은 이 영상인데, 가장 최근 작성된 영상이라는 점이 큰 장점이며 설명도 영어가 아니라서 귀가 정화된다.
https://www.youtube.com/watch?v=qL7PXAFNP5M&t=678s
이 블로그는 내가 레퍼런스를 볼때, 가장 근접한 최신 버전을 구현하고 있다.
https://velog.io/@kimwonseop/Unity-%EC%96%B4%EB%93%9C%EB%A0%88%EC%84%9C%EB%B8%94Addressable-3
Unity - 어드레서블(Addressable) (3)
서버에 에셋 업로드하기
velog.io
어드레서블 에셋 시스템으로 메모리 최적화하기 | Unity Blog
위에서 발생한 문제를 해결하기 위해 앞서 생성한 세 번들에 들어가는 모든 요소를 고려해 보겠습니다. 번들에 배치한 것은 세 가지 프리팹이지만, 프리팹의 종속성으로 해당 번들에 암묵적으
blog.unity.com
'정리 > UNITY' 카테고리의 다른 글
Menu_UI 기능 구현 (0) | 2022.04.25 |
---|---|
IL2CPP (0) | 2022.03.19 |
효율적 UI_Component 바인딩 (0) | 2022.03.08 |
Unity Shader (셰이더) (0) | 2022.03.08 |
Line Rederer (라인 렌더러) (0) | 2022.02.09 |