Unity용 빌드

이 가이드를 사용하여 Unity 프로젝트에 Play Asset Delivery를 빌드하세요.

개요

Unity AssetBundle 파일에는 앱이 실행되는 동안 Unity 엔진에서 로드할 수 있는 직렬화된 애셋이 포함되어 있습니다. 이러한 파일은 플랫폼에 따라 다르며(예: Android용으로 빌드) 애셋 팩과 함께 사용할 수 있습니다. 가장 흔하게 하나의 AssetBundle 파일은 단일 애셋 팩으로 패키징되며, 팩은 AssetBundle과 동일한 이름을 사용합니다. 애셋 팩을 더 유연하게 생성하려면 API를 사용하여 애셋 팩을 구성해야 합니다.

런타임 시 Unity용 Play Asset Delivery 클래스를 사용하여 애셋 팩에 패키징된 AssetBundle을 검색합니다.

기본 요건

  1. Play Asset Delivery용 Unity 플러그인(또는 패키지)을 다운로드합니다.

  2. Unity에서 AssetBundle을 생성합니다.

UI를 사용하여 AssetBundle 구성

  1. 다음과 같이 애셋 팩에서 각 AssetBundle을 구성합니다.

    1. Google > Android App Bundle > Asset Delivery Settings를 선택합니다.
    2. AssetBundle 파일이 직접 포함된 폴더를 선택하려면 Add Folder를 클릭합니다.

  2. 각 번들에 대해 Delivery ModeInstall Time, Fast Follow 또는 On Demand로 변경합니다. 오류 또는 종속 항목을 해결하고 창을 닫습니다.

  3. Google > Build Android App Bundle을 선택하여 App Bundle을 빌드합니다.

  4. (선택사항) 다양한 텍스처 압축 형식을 지원하도록 App Bundle을 구성합니다.

API를 사용하여 애셋 팩 구성

자동화된 빌드 시스템의 일부로 실행할 수 있는 편집기 스크립트를 통해 Asset Delivery를 구성할 수 있습니다.

AssetPackConfig 클래스를 사용하여 Android App Bundle 빌드에 포함할 애셋은 물론 애셋의 제공 모드를 정의합니다. 이러한 애셋 팩에는 AssetBundle을 포함하지 않아도 됩니다.

public void ConfigureAssetPacks {
   // Creates an AssetPackConfig with a single asset pack, named
   // examplePackName, containing all the files in path/to/exampleFolder.
   var assetPackConfig = new AssetPackConfig();
   assetPackConfig.AddAssetsFolder("examplePackName",
                                   "path/to/exampleFolder",
                                   AssetPackDeliveryMode.OnDemand);

   // Configures the build system to use the newly created assetPackConfig when
   // calling Google > Build and Run or Google > Build Android App Bundle.
   AssetPackConfigSerializer.SaveConfig(assetPackConfig);

   // Alternatively, use BundleTool.BuildBundle to build an App Bundle from script.
   BuildBundle(new buildPlayerOptions(), assetPackConfig);
}

또한 Bundletool 클래스의 정적 BuildBundle 메서드를 사용하여 BuildPlayerOptionsAssetPackConfig가 지정된 애셋 팩이 있는 Android App Bundle을 생성할 수도 있습니다.

다음 단계

Unity를 사용하여 Play Asset Delivery를 게임 또는 앱 코드에 통합합니다.