에셋번들 FAQ
소셜 API (Social API)

빌드 파일 크기 축소

Keeping the file size of the built app to a minimum is often important, especially for mobile devices or for app stores that impose a size limit. The first step in reducing the size is to determine which assets contribute most to it, since these assets are the most likely candidates for optimisation. You can find this information out from the Editor Log just after you have performed the build (select Open Editor Log from the small panel menu in the top right of the Console window).

The editor log just after a build
The editor log just after a build

The log provides a summary of assets broken down by type and then lists all the individual assets in order of size contribution. Typically, things like textures, music and videos will take up the most storage while scripts, levels and shaders are often negligible. Note that the File Headers mentioned in the summary are not assets in themselves. The headers are actually the extra data that is added to “raw” asset files to store references and settings. The headers normally make very little difference to asset size but if the value may be large if you have numerous large assets in the Resources folder.

The log helps you identify assets that you might want to remove or optimise but you should consider the following before setting to work:

  • Unity re-codes imported assets into its own internal formats, so the choice of source asset type is not relevant. For example, if you have a multi-layer Photoshop texture in the project then it will be flattened and compressed before building. Exporting the texture as a PNG file will not make any difference to build size, so you should stick to the format that is most convenient for you during development.

  • Unity strips most unused assets during the build, so you don’t gain anything by manually removing assets from the project. The only assets that are not removed are scripts (which are generally very small anyway) and assets in the Resources folder (since Unity can’t determine which of these will be needed and which won’t). With this in mind, you should make sure that the assets in the Resources folder are only the ones you really need for the game. You might be able to replace assets in Resources with AssetBundles to load assets dynamically and thereby reduce the player size.

Suggestions for Reducing Build Size

텍스처

때때로 텍스처는가 빌드의 대부분의 공간을 소비합니다. 첫째로, 압축 텍스처 형식 (DXT (Desktop platforms) 또는 PVRTC)을 사용할 수 있는 것에 사용합니다.

크기가 줄어들지 않는 경우, 텍스처의 크기를 줄여보십시오. 여기에서 포인트는 실제 소스 컨텐츠를 수정할 필요가 없다는 것입니다. 프로젝트 뷰에서 텍스처를 선택하고 임포트 설정에서 Max Size를 설정합니다. Scene View에서 외형이 나빠지기 시작할 때까지 텍스처를 사용하는 오브젝트를 확대하고 Max Size를 조정해보는 것이 좋습니다.

Max Texture Size를 변경해도, 텍스처 에셋에 영향을 주지 않고, 게임의 해상도에만 영향을 줍니다
Max Texture Size를 변경해도, 텍스처 에셋에 영향을 주지 않고, 게임의 해상도에만 영향을 줍니다

The following table shows how much storage the image formats take up in bytes per pixel:

Compression 메모리 소비 (bytes/pixel)
Standalone & WebGL
RGB Crunched DXT1 variable
RGBA Crunched DXT5 variable
RGB Compressed DXT1 0.5 bpp
RGBA Compressed DXT5 1 bpp
RGB 16bit 2 bpp
RGB 24bit 3 bpp
Alpha 8bit 1 bpp
RGBA 16bit 2 bpp
RGBA 32bit 4 bpp
iOS
RGB Compressed PVRTC 2 bits 0.25 bpp (bytes/pixel)
RGBA Compressed PVRTC 2 bits 0.25 bpp
RGB Compressed PVRTC 4 bits 0.5 bpp
RGBA Compressed PVRTC 4 bits 0.5 bpp
RGB 16bit 2 bpp
RGB 24bit 3 bpp
Alpha 8bit 1 bpp
RGBA 16bit 2 bpp
RGBA 32bit 4 bpp
Android
RGB Compressed DXT1 0.5 bpp (bytes/pixel)
RGBA Compressed DXT5 1 bpp
RGB Compressed ETC1 0.5 bpp
RGB Compressed PVRTC 2 bits 0.25 bpp (bytes/pixel)
RGBA Compressed PVRTC 2 bits 0.25 bpp
RGB Compressed PVRTC 4 bits 0.5 bpp
RGBA Compressed PVRTC 4 bits 0.5 bpp
RGB 16bit 2 bpp
RGB 24bit 3 bpp
Alpha 8bit 1 bpp
RGBA 16bit 2 bpp
RGBA 32bit 4 bpp

텍스처의 전체 크기를 구하는 방법은 : 폭 * 높이 * bpp. 미니 맵이 있는 경우는 3배 이상으로 합니다.

기본적으로 Unity는 임포트할 때 모든 텍스처를 압축합니다. 워크 플로우를 더욱 빠르게 하기 위해 Preferences에서 이것을 해제할 수 있습니다. 게임 작성시, 압축되지 않은 모든 텍스처가 압축됩니다.

메쉬 및 애니메이션

게임 파일의 사용 공간을 줄일 수 있도록, Meshes(class-Mesh) 및 임포트된 애니메이션 클립을 압축할 수 있습니다. 메쉬 임포트 설정에서 압축을 설정할 수 있습니다.

메쉬와 애니메이션 압축은 적은 공간 사용이 적어 지지만, 정밀하지 않은 데이터가 되는 것에 주의하십시오. 당신의 모델에서 허용 가능한 압축 레벨을 시도해보십시오.

메쉬 압축은 작은 데이터 파일만 생성하지 않고, 런타임에서 사용하는 메모리는 적어지는 점에 유의하십시오. 애니메이션 Keyframe reduction은 작은 데이터 파일만 생성하고, 런타임에서 사용하는 메모리는 줄어들어 일반적으로 항상 키 프레임 절감을 사용합니다.

DLLs

기본적으로 Unity는 빌드된 플레이어에서만 다음 DLL을 포함합니다 :

  • mscorlib.dll
  • Boo.Lang.dll
  • UnityScript.Lang.dll
  • UnityEngine.dll

When building a player, you should avoid any dependencies on System.dll or System.Xml.dll. Unity does not include these in the built player by default but if you use their classes then they will get included. These DLLs will add about a megabyte to the player’s storage size. If you need to parse XML in your game, you can use a library like Mono.Xml.zip as a smaller alternative to the system libraries. While most Generic containers are contained in mscorlib, Stack<> and few others are in System.dll, so you should avoid these if possible.

As you can see, Unity is including System.Xml.dll and System.dll, when building a player
As you can see, Unity is including System.Xml.dll and System.dll, when building a player

모바일용 .NET Library의 크기 감소

Unity supports two .NET API compatibility levels for some mobile devices: .NET 2.0 and a subset of .NET 2.0. You can select the appropriate level for your build in the Player Settings.

The .NET 2.0 API profile is similar to the full .NET 2.0 API. Most library routines are fully implemented and so this option offers the best compatibility with pre-existing .NET code. However, for many games, the full library is not needed and the superfluous code takes up valuable memory space.

To avoid wasted memory, Unity also supports the .NET 2.0 Subset API profile. This is very similar to the Mono “monotouch” profile, so many limitations of the “monotouch” profile also apply to Unity’s .NET 2.0 Subset profile. (More information on the limitations of the “monotouch” profile can be found here). Many library routines that are not commonly needed in games are left out of this profile in order to save memory. However, this also means that code with dependencies on those routines will not work correctly. This option can be a useful optimization but you should check that existing code still works after it is applied.

에셋번들 FAQ
소셜 API (Social API)