unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅

Gradle for Android

Gradle is an Android build system that automates a number of build processes and prevents many common build errors. In Unity, Gradle reduces the method reference count in DEX (Dalvik Executable format) files, which means you are less likely to come across DEX limit problems.

Unity versionGradle version
2020.3 starting from 2020.3.15f16.1.1
2020.1, 2020.2, 2020.3 up to and including 2020.3.14f15.6.4
2019.45.1.1

To learn more about:

Building or exporting a Gradle project

To build a Gradle project, follow these steps:

Exported Gradle project structure

Unity 2019.3 and newer versions create a Gradle project with two modules:

build.gradle templates

Gradle templates describe and configure how to build your Android app with Gradle. Each Gradle template represents a singleGradle project. Gradle projects can include, and depend on other Gradle projects.

A Gradle template consists of the following files:

Customizing your Gradle build

You can provide a custom Gradle build template and select minification options in the Publishing Settings section of the Player Settings Settings that let you set various player-specific options for the final game built by Unity. More info
See in Glossary window.

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅

Providing a custom Gradle build template

You can use a custom build.gradle file for the unityLibrary module when you build the APK from Unity. This file contains specific build instructions specified in template variables. For a list of template variables, see the next section.

To use your own build.gradle file for the unityLibrary module, follow these steps:

Unity then generates a default mainTemplate.gradle file in your Project’s Assets/Plugins/Android/ folder. The path to the new file also appears under the Custom Main Gradle Template option in the Player Settings. Double-click the mainTemplate.gradle file in the Project view to open it in an external text editor.

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅mainTemplate.gradle file in the Project view for the unityLibrary module

By default, Unity uses the settingsTemplate.gradle file from the Unity install directory to create the settings.gradle file for your build. The settings.gradle file contains project components which are involved in the build process. Unity creates the following components by default, which should always be included in the settings.gradle file:

Additionally, if you add Android library plugins to your project, Unity automatically includes them in the settings file by replacing the **INCLUDES** entry.

If you want to add additional components to the settings.gradle file that Unity doesn’t include by default, create a settingsTemplate.gradle file in your project’s Assets/Plugins/Android/ folder. This overrides the default template.

If you use your own settingsTemplate.gradle file, it must contain the following lines:

IPostGenerateGradleAndroidProject

IPostGenerateGradleAndroidProject returns the path to the unityLibrary module. This keeps everything similar to versions earlier than Unity 2019.3 and doesn’t require any further changes, which means Unity can reach the app’s manifest and resources in a consistent way across versions.

Template variables

The mainTemplate.gradle file can contain the following variables:

Variable:Description:
DEPSList of project dependencies In the context of the Package Manager, a dependency is a specific package version (expressed in the form package_name@package_version ) that a project or another package requires in order to work. Projects and packages use the dependencies attribute in their manifests to define the set of packages they require. For projects, these are considered direct dependencies; for packages, these are indirect, or transitive, dependencies. More info
See in Glossary ; that is, the libraries that the Project uses.
APIVERSIONAPI version to build for (for example, 25).
MINSDKVERSIONMinimum API version (for example, 25).
BUILDTOOLSSDK Build tools used (for example, 25.0.1).
TARGETSDKVERSIONAPI version to target (for example, 25).
APPLICATIONIDAndroid Application ID (for example, com.mycompany.myapp).
MINIFY_DEBUGEnable minify for debug builds (true or false).
PROGUARD_DEBUGUse proguard for minification in debug builds (true or false.)
MINIFY_RELEASEEnable minify for release builds (true or false).
PROGUARD_RELEASEUse proguard for minification in release builds (true or false).
USER_PROGUARDCustom user proguard file (for example, proguard-user.txt ).
SIGNComplete the signingConfigs section if this build is signed.
SIGNCONFIGSet to signingConfig signingConfig.release if this build is signed.
DIR_GRADLEPROJECTThe directory where Unity creates the Gradle project.
DIR_UNITYPROJECTThe directory of your Unity Project.

Minification

You can use Proguard minification to shrink and optimize your app. To activate this option, follow these steps:

Note: Proguard might strip out important code that your app needs, so use these options carefully.

To generate a custom proguard.txt file, enable the User Proguard File setting in the Publishing Settings section of the Player Settings. This immediately generates the proguard.txt file in your Project’s Assets/Plugins/Android/ folder.

To learn more about ProGuard, see the ProGuard manual.

Errors when building with Gradle

If an error occurs when you use Gradle to build your app for Android, Unity displays an error dialog box. Select the Troubleshoot button to open the Gradle troubleshooting Unity documentation in your system’s browser.

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

Unity: Π‘Π±ΠΎΡ€ΠΊΠ° ΠΏΠΎΠ΄ Android ΠΈΠ»ΠΈ Β«Ρ€Π°Π·ΠΌΠ΅Ρ€ ΠΈΠΌΠ΅Π΅Ρ‚ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅Β»

Π’ Π½Π΅ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Ρ… случаях Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π°Π΄ сниТСниСм Ρ€Π°Π·ΠΌΠ΅Ρ€Π° сборки для Андроид. НапримСр, установка тяТСловСсных APK для ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ мобильного ΠΈΠ½Ρ‚Π΅Ρ€Π½Π΅Ρ‚Π° ΠΌΠΎΠΆΠ΅Ρ‚ Π²Π»Π΅Ρ‚Π΅Ρ‚ΡŒ Π² ΠΊΠΎΠΏΠ΅Π΅Ρ‡ΠΊΡƒ. ΠŸΡ€Π΅Π²Ρ‹ΡˆΠ΅Π½ΠΈΠ΅ Ρ€Π°Π·ΠΌΠ΅Ρ€Π° APK Π² 50 Мб Π² Google Play выливаСтся Π² Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ трудности ΠΏΡ€ΠΈ Π°ΠΏΠ»ΠΎΠ°Π΄Π΅.

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅

ΠœΡ‹ Ρ€Π°Π·Ρ€Π°Π±Π°Ρ‚Ρ‹Π²Π°Π»ΠΈ ΠΏΠΎΠ΄ Андроид Π½Π° Unity 2D-ΠΈΠ³Ρ€Ρƒ, которая ΠΈΠ·ΠΎΠ±ΠΈΠ»ΡƒΠ΅Ρ‚ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ°ΠΌΠΈ (Π±ΠΎΠ»ΡŒΡˆΠΈΠ½ΡΡ‚Π²ΠΎ с областями прозрачности) ΠΈ Ρ€Π°Π·Π½ΠΎΠΎΠ±Ρ€Π°Π·Π½Ρ‹ΠΌΠΈ Π·Π²ΡƒΠΊΠ°ΠΌΠΈ, ΠΈ ΡΡ‚ΠΎΠ»ΠΊΠ½ΡƒΠ»ΠΈΡΡŒ с ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΠΎΠΉ Ρ€Π°Π·ΠΌΠ΅Ρ€Π° APK. ЗабСгая Π²ΠΏΠ΅Ρ€Π΅Π΄ скаТу, Ρ‡Ρ‚ΠΎ Ρ€Π΅ΡˆΠΈΠ² Π΅Π΅ ΠΈ снизив вСс Π² 1,5 Ρ€Π°Π·Π°, ΠΌΡ‹ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ Π² 1,5 Ρ€Π°Π·Π° большС скачиваний. ЗаставляСт Π·Π°Π΄ΡƒΠΌΠ°Ρ‚ΡŒΡΡ, Π½Π΅ ΠΏΡ€Π°Π²Π΄Π° Π»ΠΈ?

ΠŸΡ‹Ρ‚Π°ΡΡΡŒ ΠΏΠΎΠ±ΠΎΡ€ΠΎΡ‚ΡŒ ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΡƒ ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ-тяТСловСсов, ΠΌΡ‹ ΠΎΠ±Ρ€Π°Ρ‚ΠΈΠ»ΠΈΡΡŒ ΠΊ Π·Π°ΠΌΠ΅Ρ‡Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎΠΉ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΠΈ ΠΎΡ‚ Unity. Π’Ρ‹ΡΡΠ½ΠΈΠ»ΠΎΡΡŒ, Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΌ данная Ρ‚Π΅ΠΌΠ° обсуТдаСтся лишь вскользь. УпоминаСтся, ΠΊΠ°ΠΊΠΈΠ΅ ΠΈΠΌΠ΅Π½Π½ΠΎ аспСкты Π²Π»ΠΈΡΡŽΡ‚ Π½Π° Ρ€Π°Π·ΠΌΠ΅Ρ€ сборки ΠΈ ΠΊΠ°ΠΊ Π²ΠΎΠ·Π΄Π΅ΠΉΡΡ‚Π²ΠΎΠ²Π°Ρ‚ΡŒ Π½Π° эти аспСкты, Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ APK мСньшС, Π° Ρ‚Π°ΠΊΠΆΠ΅ ΠΏΡ€ΠΈΠ²Π΅Π΄Π΅Π½ΠΎ Π½Π΅ΠΌΠ½ΠΎΠ³ΠΎ ΠΊΠΎΠ½ΠΊΡ€Π΅Ρ‚ΠΈΠΊΠΈ ΠΏΠΎ ΠΏΠΎΠ²ΠΎΠ΄Ρƒ настроСк ΠΈΠΌΠΏΠΎΡ€Ρ‚Π° ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΉ.

Π”Ρ€ΡƒΠ³ΡƒΡŽ ΠΏΠΎΠ»Π΅Π·Π½ΡƒΡŽ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡŽ ΠΏΠΎ Π΄Π°Π½Π½ΠΎΠΌΡƒ вопросу Π² ΠΈΠ½Ρ‚Π΅Ρ€Π½Π΅Ρ‚Π΅ ΠΌΡ‹ практичСски Π½Π΅ нашли. ΠŸΠΎΡ‚ΠΎΠΌΡƒ ΠΏΡ€ΠΎΠ²Π΅Π»ΠΈ нСбольшоС исслСдованиС, Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Π°ΠΌΠΈ ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠ³ΠΎ спСшим с Π²Π°ΠΌΠΈ ΠΏΠΎΠ΄Π΅Π»ΠΈΡ‚ΡŒΡΡ.

Π˜Π—ΠžΠ‘Π ΠΠ–Π•ΠΠ˜Π―

Π£Ρ‚ΠΎΡ‡Π½ΠΈΠΌ насчёт ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΉ. Π’ нашСй ΠΈΠ³Ρ€Π΅ ΡΠΎΠ±Π»ΡŽΠ΄Π°Π΅Ρ‚ΡΡ ΠΏΡ€ΠΈΠ½Ρ†ΠΈΠΏ pixel-perfect. ВсС изобраТСния Π±Π΅Π· Π°Π»ΡŒΡ„Π°-ΠΊΠ°Π½Π°Π»Π° ΠΈΠΌΠ΅ΡŽΡ‚ ΠΏΠ»Π°Π²Π½Ρ‹ΠΉ Π³Ρ€Π°Π΄ΠΈΠ΅Π½Ρ‚. ΠžΡΡ‚Π°Π»ΡŒΠ½Ρ‹Π΅ изобраТСния с ΠΏΡ€ΠΎΠ·Ρ€Π°Ρ‡Π½ΠΎΡΡ‚ΡŒΡŽ, Π° Π½Π΅ΠΏΡ€ΠΎΠ·Ρ€Π°Ρ‡Π½Ρ‹Π΅ области Ρ‚ΠΎΠΆΠ΅ ΠΈΠΌΠ΅ΡŽΡ‚ ΠΏΠ»Π°Π²Π½Ρ‹ΠΉ Π³Ρ€Π°Π΄ΠΈΠ΅Π½Ρ‚.

ΠŸΡ€ΠΎΠ°Π½Π°Π»ΠΈΠ·ΠΈΡ€ΡƒΠ΅ΠΌ, ΠΊΠ°ΠΊΠΎΠΉ Π²ΠΊΠ»Π°Π΄ Π² Ρ€Π°Π·ΠΌΠ΅Ρ€ АРК вносят изобраТСния Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ PNG ΠΈ JPG.

ΠšΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ PNG

Π”Π°Π»Π΅Π΅ ΠΌΡ‹ сохранили ΠΏΠ΅Ρ€Π²ΡƒΡŽ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ Π² Photoshop с настройками: Compression->None/Fast, Intrelaced: Yes. ΠŸΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ Ρ„Π°ΠΉΠ» Ρ€Π°Π·ΠΌΠ΅Ρ€ΠΎΠΌ 9000 ΠšΠ±Π°ΠΉΡ‚, ΠΎΠ΄Π½Π°ΠΊΠΎ Π² сборку ΠΎΠ½ Π΄ΠΎΠ±Π°Π²ΠΈΠ» Ρ‚Π΅ ΠΆΠ΅ 236 ΠšΠ±Π°ΠΉΡ‚.

Π­Ρ‚ΠΎ ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π°Π΅Ρ‚ слова ΠΈΠ· Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΠΈ, ΠΎ Ρ‚ΠΎΠΌ, Ρ‡Ρ‚ΠΎ Unity ΠΏΠ΅Ρ€Π΅ΠΊΠΎΠ΄ΠΈΡ€ΡƒΠ΅Ρ‚ всС ассСты Π²ΠΎ Π²Π½ΡƒΡ‚Ρ€Π΅Π½Π½ΠΈΠΉ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚. ΠžΡ‡Π΅Π²ΠΈΠ΄Π½ΠΎ, ΠΎΠ½ ΠΏΡ€ΠΈΠ±Π»ΠΈΠ·ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ соотвСтствуСт Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Ρƒ PNG, сохранённому Π² Ρ„ΠΎΡ‚ΠΎΡˆΠΎΠΏΠ΅ с настройками: Compression->Smallest/Slow, Intrelaced: No. И Unity ΠΏΠ΅Ρ€Π΅ΠΊΠΎΠ΄ΠΈΡ€ΡƒΠ΅Ρ‚ всС PNG Π² этот Ρ„ΠΎΡ€ΠΌΠ°Ρ‚, нСзависимо ΠΎΡ‚ Π½Π°Ρ‡Π°Π»ΡŒΠ½ΠΎΠ³ΠΎ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π° Ρ„Π°ΠΉΠ»Π°.

ΠšΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ JPG

ΠžΠΏΡ‹Ρ‚Ρ‹ ΠΎΠ΄Π½ΠΎΠ·Π½Π°Ρ‡Π½ΠΎ ΠΏΠΎΠΊΠ°Π·Π°Π»ΠΈ, Ρ‡Ρ‚ΠΎ изобраТСния JPG вносят Π²ΠΊΠ»Π°Π΄ Π² Ρ€Π°Π·ΠΌΠ΅Ρ€ сборки ΠΏΡ€ΠΎΠΏΠΎΡ€Ρ†ΠΈΠΎΠ½Π°Π»ΡŒΠ½ΠΎ своСму Ρ€Π°Π·ΠΌΠ΅Ρ€Ρƒ. Пока Π½Π΅ совсСм понятно, ΠΊΠ°ΠΊ Π²Π΅Π΄Ρ‘Ρ‚ сСбя Unity Π² случаС, Ссли ассСт находится Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ JPG. ΠœΡ‹ сохранили Ρ‚Ρƒ ΠΆΠ΅ ΡΠ°ΠΌΡƒΡŽ (ΠΏΠ΅Ρ€Π²ΡƒΡŽ) ΠΊΠ°Ρ€Ρ‚ΠΈΠΊΡƒ Π² JPG ΠΈ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ»ΠΈ ΠΎΡ‡Π΅Π½ΡŒ малСнький Ρ„Π°ΠΉΠ» Π½Π° Ρ„Π°ΠΉΠ»ΠΎΠ²ΠΎΠΉ систСмС (75 ΠšΠ±Π°ΠΉΡ‚). Однако Π² сборкС ΠΎΠ½ занял Π½Π΅ΠΏΠΎΠΌΠ΅Ρ€Π½Ρ‹Ρ… 767 ΠšΠ±Π°ΠΉΡ‚ (*).

ΠœΡ‹ ΠΏΡ€ΠΎΠ²ΠΎΠ΄ΠΈΠ»ΠΈ экспСримСнт Π½Π° большом количСствС Ρ€Π°Π·Π½Ρ‹Ρ… ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΎΠΊ, здСсь я ΠΏΡ€ΠΈΠ²ΠΎΠΆΡƒ лишь ΠΌΠ°Π»ΡƒΡŽ Ρ‡Π°ΡΡ‚ΡŒ исслСдований. Π’ Π΄Ρ€ΡƒΠ³ΠΈΡ… экспСримСнтах Π½Π°ΠΌ Π½Π°ΠΎΠ±ΠΎΡ€ΠΎΡ‚ ΡƒΠ΄Π°Π²Π°Π»ΠΎΡΡŒ ΡΠ½ΠΈΠ·ΠΈΡ‚ΡŒ ΠΎΠ±Ρ‰ΠΈΠΉ Ρ€Π°Π·ΠΌΠ΅Ρ€ сборки ΠΊΠΎΠ½Π²Π΅Ρ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ всСх Ρ„Π°ΠΉΠ»ΠΎΠ² ΠΈΠ· PNG Π² JPG.
ΠŸΡ€ΠΈΡ‡ΠΈΠ½ этого явлСния Π²Ρ‹ΡΠ²ΠΈΡ‚ΡŒ ΠΏΠΎΠΊΠ° Π½Π΅ ΡƒΠ΄Π°Π»ΠΎΡΡŒ.
Π‘ΠΊΠΎΡ€Π΅Π΅ всСго, снова ΠΈΠΌΠ΅Π΅Ρ‚ мСсто Π²Π½ΡƒΡ‚Ρ€Π΅Π½Π½ΠΈΠΉ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚ Unity, ΠΎΠ΄Π½Π°ΠΊΠΎ Ρ‚ΠΎΡ‡Π½Ρ‹Π΅ ΠΏΡ€ΠΈΠ½Ρ†ΠΈΠΏΡ‹ взаимодСйствия колдовского ΠΌΠ΅Ρ…Π°Π½ΠΈΠ·ΠΌΠ° Unity с ассСтами JPG Π²Ρ‹ΡΡΠ½ΠΈΡ‚ΡŒ ΠΏΠΎΠΊΠ° Π½Π΅ ΡƒΠ΄Π°Π»ΠΎΡΡŒ.

Π•Ρ‰Π΅ ΠΎΠ΄ΠΈΠ½ способ Ρ€Π°Π±ΠΎΡ‚Ρ‹ с JPG Π±ΡƒΠ΄Π΅Ρ‚ описан Π½ΠΈΠΆΠ΅.

Π—Π’Π£ΠšΠ˜

Для Π·Π²ΡƒΠΊΠΎΠ² Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ ΠΈΠΌΠ΅ΡŽΡ‚ Π΄Π²Π΅ настройки ΠΈΠΌΠΏΠΎΡ€Ρ‚Π°: Audio Format ΠΈ ForceToMono.

Π€Π°ΠΉΠ»Ρ‹ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ WAV Π·Π°Π½ΠΈΠΌΠ°ΡŽΡ‚ большС мСста Π² сборкС, Ρ‡Π΅ΠΌ Ρ„Π°ΠΉΠ»Ρ‹ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ MP3 (Π²ΠΊΠ»Π°Π΄ Π² Ρ€Π°Π·ΠΌΠ΅Ρ€ сборки ΠΏΡ€ΠΈΠ±Π»ΠΈΠ·ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ Ρ€Π°Π²Π΅Π½ Ρ€Π°Π·ΠΌΠ΅Ρ€Ρƒ Ρ„Π°ΠΉΠ»Π°). Π‘Ρ‚Π΅Ρ€Π΅ΠΎ WAV Ρ„Π°ΠΉΠ» Π·Π°ΠΉΠΌΡ‘Ρ‚ мСньшС мСста, Ссли Π²Ρ‹ΡΡ‚Π°Π²ΠΈΡ‚ΡŒ ForceToMono = true. Π’ΠΎΡ‡Π½ΠΎ Ρ‚Π°ΠΊΠΎΠ³ΠΎ ΠΆΠ΅ эффСкта ΠΌΠΎΠΆΠ½ΠΎ Π΄ΠΎΡΡ‚ΠΈΡ‡ΡŒ, Ссли ΠΊΠΎΠ½Π²Π΅Ρ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Ρ„Π°ΠΉΠ» Π² Β«ΠΌΠΎΠ½ΠΎΒ» Π΅Ρ‰Ρ‘ Π΄ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚Π° (Ρ‚ΠΎΠ³Π΄Π° ForceToMono Π½Π΅ Π±ΡƒΠ΄Π΅Ρ‚ доступна Π² инспСкторС).

Однако Ссли для Ρ„Π°ΠΉΠ»Π° WAV ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ настройку ΠΈΠΌΠΏΠΎΡ€Ρ‚Π° AudioFormat = Compressed, Ρ‚ΠΎ Π² сборкС ΠΎΠ½ Π·Π°ΠΉΠΌΡ‘Ρ‚ мСста ΡΡ‚ΠΎΠ»ΡŒΠΊΠΎ ΠΆΠ΅, сколько ΠΈ ΡΠΎΠΎΡ‚Π²Π΅Ρ‚ΡΡ‚Π²ΡƒΡŽΡ‰ΠΈΠΉ MP3 Ρ„Π°ΠΉΠ» Π²Ρ‹ΡΡˆΠ΅Π³ΠΎ качСства (Audacity: variable bitrate, 220-260 kbps). Π’ΠΎ Π΅ΡΡ‚ΡŒ Unity ΡΠ°ΠΌΠΎΡΡ‚ΠΎΡΡ‚Π΅Π»ΡŒΠ½ΠΎ ΠΊΠΎΠ΄ΠΈΡ€ΡƒΠ΅Ρ‚ Π·Π²ΡƒΠΊ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚ MP3.

Для Ρ„Π°ΠΉΠ»ΠΎΠ² Π² ΠΎΠ΄ΠΈΠ½Π°ΠΊΠΎΠ²ΠΎΠΌ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ дСйствуСт ΠΏΡ€ΠΈΠ½Ρ†ΠΈΠΏ прямо ΠΏΡ€ΠΎΠΏΠΎΡ€Ρ†ΠΈΠΎΠ½Π°Π»ΡŒΠ½ΠΎΠ³ΠΎ Π²ΠΊΠ»Π°Π΄Π° Π² Ρ€Π°Π·ΠΌΠ΅Ρ€ сборки.

ΠžΡΡ‚Π°Π»ΡŒΠ½Ρ‹Π΅ настройки ΠΈΠΌΠΏΠΎΡ€Ρ‚Π° Π½Π° Ρ€Π°Π·ΠΌΠ΅Ρ€ сборки Π½ΠΈΠΊΠ°ΠΊ Π½Π΅ Π²Π»ΠΈΡΡŽΡ‚. Они Π²Π»ΠΈΡΡŽΡ‚ Π½Π° количСство мСста, Π·Π°Π½ΠΈΠΌΠ°Π΅ΠΌΠΎΠ΅ Π·Π²ΡƒΠΊΠΎΠΌ Π² RAM.

А Π’Π•ΠŸΠ•Π Π¬ О ΠšΠžΠΠšΠ Π•Π’ΠΠ«Π₯ ШАГАΠ₯ К НАШЕЙ Π¦Π•Π›Π˜

Π’Π°ΠΊΠΈΠΌ ΠΎΠ±Ρ€Π°Π·ΠΎΠΌ, совСт: для сниТСния Π½Π°Π³Ρ€ΡƒΠ·ΠΊΠΈ Π½Π° ΠžΠ—Π£
* ΠΈΠ·Π±Π΅Π³Π°Ρ‚ΡŒ Π±ΠΎΠ»ΡŒΡˆΠΈΡ… областСй прозрачности Π² изобраТСниях;
* Π½Π΅ Ρ„ΠΎΡ€ΠΌΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ атласы с большими участками прозрачности, особСнно Π² NGUI.

(Но это ΠΌΡ‹ ΠΎΡ‚Π²Π»Π΅ΠΊΠ»ΠΈΡΡŒ ΠΎΡ‚ основной Ρ‚Π΅ΠΌΡ‹.)

НСсколько слов о dll

Π”ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚ ΠΏΡ€ΠΈΠ²ΠΎΠ΄ΠΈΡ‚ список ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎ Π²ΠΊΠ»ΡŽΡ‡Π°Π΅ΠΌΡ‹Ρ… Π² сборку dll ΠΈ ΠΏΡ€ΠΈΠ·Ρ‹Π²Π°Π΅Ρ‚ ΠΌΠΈΠ½ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ количСство Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Ρ… dll (особСнно тяТёлых). Π’ частности, ΠΏΠΎ возмоТности Π½Π΅ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ System.dll (добавляСт ΠΊ APK 2 ΠœΠ±Π°ΠΉΡ‚). Однако Π΄Π°ΠΆΠ΅ Ссли ΠΌΡ‹ Π±ΡƒΠ΄Π΅ΠΌ ΠΈΠ·Π±Π΅Π³Π°Ρ‚ΡŒ ссылок Π½Π° ΠΌΠ΅Ρ‚ΠΎΠ΄Ρ‹ ΠΈΠ· этой Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ, System.dll всё Ρ€Π°Π²Π½ΠΎ (ΠΏΠΎ ΡΠΎΡΡ‚ΠΎΡΠ½ΠΈΡŽ Π½Π° Unity 4.5.5) Π²ΠΊΠ»ΡŽΡ‡Π°Π΅Ρ‚ΡΡ Π² сборку, Ρ‚Π°ΠΊ ΠΊΠ°ΠΊ Π΅Ρ‘ подтягиваСт ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Π°Ρ Mono.Security.dll. ΠŸΠΎΡ‚ΠΎΠΌΡƒ, получаСтся, Ρ‡Ρ‚ΠΎ ΠΎΡ„ΠΈΡ†ΠΈΠ°Π»ΡŒΠ½Π°Ρ докумСнтация Unity Π² этом мСстС Π½Π΅ совсСм Ρ€Π΅Π»Π΅Π²Π°Π½Ρ‚Π½Π°.

А Π²ΠΎΡ‚ использования Π΄Ρ€ΡƒΠ³ΠΈΡ… (Π½Π΅ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Ρ…) dll ΠΆΠ΅Π»Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎ ΠΈΠ·Π±Π΅Π³Π°Ρ‚ΡŒ Π²ΠΎ имя сниТСния Ρ€Π°Π·ΠΌΠ΅Ρ€Π° сборки.

На сСгодня Ρƒ нас всё. Бпасибо Π·Π° Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅!

(ΠŸΡ€ΠΎΡΡŒΠ±Π° Ρ€Π°ΡΡΠΌΠ°Ρ‚Ρ€ΠΈΠ²Π°Ρ‚ΡŒ Π΄Π°Π½Π½Ρ‹ΠΉ ΠΌΠ°Ρ‚Π΅Ρ€ΠΈΠ°Π» ΠΊΠ°ΠΊ Π±ΠΎΠ»Π΅Π΅-ΠΌΠ΅Π½Π΅Π΅ систСматизированныС Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Ρ‹ исслСдования, Π° Π½Π΅ ΠΊΠ°ΠΊ ΡƒΠ½ΠΈΠ²Π΅Ρ€ΡΠ°Π»ΡŒΠ½ΠΎΠ΅ руководство ΠΊ Π΄Π΅ΠΉΡΡ‚Π²ΠΈΡŽ. Π‘ΡƒΠ΄Ρƒ ΠΎΡ‡Π΅Π½ΡŒ Ρ€Π°Π΄ коммСнтариям, замСчаниям, конструктивной ΠΊΡ€ΠΈΡ‚ΠΈΠΊΠ΅, возраТСниям, прСдлоТСниям, дополнСниям. И, ΠΊΠΎΠ½Π΅Ρ‡Π½ΠΎ, нСсказанно Ρ€Π°Π΄ Π±ΡƒΠ΄Ρƒ ΡƒΠ·Π½Π°Ρ‚ΡŒ, ΠΊΠ°ΠΊΠΈΠ΅ ΠΏΡ€ΠΈΡ‘ΠΌΡ‹ ΠΏΡ€ΠΈΠΌΠ΅Π½ΡΡŽΡ‚ ΠΊΠΎΠ»Π»Π΅Π³ΠΈ ΠΈΠ· Π΄Ρ€ΡƒΠ³ΠΈΡ… ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΉ для Ρ€Π΅ΡˆΠ΅Π½ΠΈΡ обсуТдаСмого вопроса.)

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

ПишСм ΠΏΠ»Π°Π³ΠΈΠ½ для Unity ΠΏΡ€Π°Π²ΠΈΠ»ΡŒΠ½ΠΎ. Π§Π°ΡΡ‚ΡŒ 2: Android

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅

Π’ ΠΏΡ€Π΅Π΄Ρ‹Π΄ΡƒΡ‰Π΅ΠΉ части ΠΌΡ‹ рассмотрСли основныС ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΡ‹ написания Π½Π°Ρ‚ΠΈΠ²Π½Ρ‹Ρ… ΠΏΠ»Π°Π³ΠΈΠ½ΠΎΠ² Π½Π° Unity ΠΏΠΎΠ΄ iOS ΠΈ Android, Π° Ρ‚Π°ΠΊΠΆΠ΅ ΠΌΠ΅Ρ‚ΠΎΠ΄Ρ‹ ΠΈΡ… Ρ€Π΅ΡˆΠ΅Π½ΠΈΡ для iOS. Π’ этой ΡΡ‚Π°Ρ‚ΡŒΠ΅ я ΠΎΠΏΠΈΡˆΡƒ основныС Ρ€Π΅Ρ†Π΅ΠΏΡ‚Ρ‹ ΠΏΠΎ Ρ€Π΅ΡˆΠ΅Π½ΠΈΡŽ этих ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌ для Android, ΡΡ‚Π°Ρ€Π°ΡΡΡŒ ΡΠΎΡ…Ρ€Π°Π½ΠΈΡ‚ΡŒ ΡΡ…ΠΎΠΆΡƒΡŽ структуру взаимодСйствия ΠΈ порядок ΠΈΡ… рассмотрСния.

Π‘ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ для Android Π² Unity ΠΌΠΎΠ³ΡƒΡ‚ Π±Ρ‹Ρ‚ΡŒ прСдставлСны Π² Π²ΠΈΠ΄Π΅ Jar (Ρ‚ΠΎΠ»ΡŒΠΊΠΎ скомпилированный java ΠΊΠΎΠ΄), Aar (скомпилированный java ΠΊΠΎΠ΄ вмСстС с рСсурсами ΠΈ манифСстом), ΠΈ исходников. Π’ исходниках ΠΆΠ΅Π»Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎ Ρ…Ρ€Π°Π½ΠΈΡ‚ΡŒ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ спСцифичный для Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° ΠΊΠΎΠ΄ с ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡŒΠ½Ρ‹ΠΌ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π»ΠΎΠΌ, ΠΈ Ρ‚ΠΎ это Π½Π΅ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎ ΠΈ Π½Π΅ ΠΎΡ‡Π΅Π½ΡŒ ΡƒΠ΄ΠΎΠ±Π½ΠΎ. Π›ΡƒΡ‡ΡˆΠΈΠΉ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚ β€” завСсти ΠΎΡ‚Π΄Π΅Π»ΡŒΠ½Ρ‹ΠΉ gradle ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ (ΠΌΠΎΠΆΠ½ΠΎ прямо Π² Ρ€Π΅ΠΏΠΎΠ·ΠΈΡ‚ΠΎΡ€ΠΈΠΈ с основным Unity ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ΠΎΠΌ), Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ ΠΌΠΎΠΆΠ½ΠΎ Ρ€Π°Π·ΠΌΠ΅ΡΡ‚ΠΈΡ‚ΡŒ Π½Π΅ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ ΠΊΠΎΠ΄ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ, Π½ΠΎ ΠΈ unit-тСсты, ΠΈ тСстовый Android ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ с Activity для быстрой сборки ΠΈ ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π»Π° Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ. А Π² gradle скрипт сборки этого ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° ΠΌΠΎΠΆΠ½ΠΎ сразу Π΄ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ task, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π±ΡƒΠ΄Π΅Ρ‚ ΠΊΠΎΠΏΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ скомпилированный Aar Π² Assets:

Π—Π΄Π΅ΡΡŒ my-plugin β€” Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ; deployAarPath β€” ΠΏΡƒΡ‚ΡŒ, ΠΏΠΎ ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌΡƒ копируСтся ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡ€ΡƒΠ΅ΠΌΡ‹ΠΉ Ρ„Π°ΠΉΠ», ΠΌΠΎΠΆΠ΅Ρ‚ Π±Ρ‹Ρ‚ΡŒ Π»ΡŽΠ±Ρ‹ΠΌ.

Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ Jar сСйчас Ρ‚Π°ΠΊΠΆΠ΅ Π½Π΅ΠΆΠ΅Π»Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎ, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ Unity ΡƒΠΆΠ΅ Π΄Π°Π²Π½ΠΎ Π½Π°ΡƒΡ‡ΠΈΠ»Π°ΡΡŒ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΈΠ²Π°Ρ‚ΡŒ Aar, Π° ΠΎΠ½ Π΄Π°Π΅Ρ‚ большС возмоТностСй: ΠΊΡ€ΠΎΠΌΠ΅ ΠΊΠΎΠ΄Π° ΠΌΠΎΠΆΠ½ΠΎ Π²ΠΊΠ»ΡŽΡ‡Π°Ρ‚ΡŒ рСсурсы ΠΈ свой AndroidManifest.xml, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π±ΡƒΠ΄Π΅Ρ‚ ΡΠ»ΠΈΠ²Π°Ρ‚ΡŒΡΡ с основным ΠΏΡ€ΠΈ gradle-сборкС. Π‘Π°ΠΌΠΈ Ρ„Π°ΠΉΠ»Ρ‹ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊ Π½Π΅ ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎ ΡΠΊΠ»Π°Π΄Ρ‹Π²Π°Ρ‚ΡŒ Π² Assets/Plugins/Android. ΠŸΡ€Π°Π²ΠΈΠ»ΠΎ дСйствуСт Ρ‚Π°ΠΊΠΎΠ΅ ΠΆΠ΅, ΠΊΠ°ΠΊ ΠΈ для iOS: Ссли ΠΏΠΈΡˆΠ΅Ρ‚Π΅ ΡΡ‚ΠΎΡ€ΠΎΠ½Π½ΡŽΡŽ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΡƒ, складывайтС всС Π² ΠΏΠΎΠ΄ΠΏΠ°ΠΏΠΊΡƒ Π²Π½ΡƒΡ‚Ρ€ΠΈ вашСй спСцифичСской ΠΏΠ°ΠΏΠΊΠΈ с ΠΊΠΎΠ΄ΠΎΠΌ ΠΈ Π½Π°Ρ‚ΠΈΠ²Π½Ρ‹ΠΌ ΠΊΠΎΠ΄ΠΎΠΌ для iOS β€” ΠΏΡ€ΠΎΡ‰Π΅ Π±ΡƒΠ΄Π΅Ρ‚ ΠΏΠΎΡ‚ΠΎΠΌ ΠΎΠ±Π½ΠΎΠ²Π»ΡΡ‚ΡŒ ΠΈΠ»ΠΈ ΡƒΠ΄Π°Π»ΡΡ‚ΡŒ ΠΏΠ°ΠΊΠ΅Ρ‚Ρ‹. Π’ Π΄Ρ€ΡƒΠ³ΠΈΡ… случаях ΠΌΠΎΠΆΠ½ΠΎ Ρ…Ρ€Π°Π½ΠΈΡ‚ΡŒ, Π³Π΄Π΅ хочСтся, Π² настройках ΠΈΠΌΠΏΠΎΡ€Ρ‚Π° Unity ΠΌΠΎΠΆΠ½ΠΎ ΡƒΠΊΠ°Π·Π°Ρ‚ΡŒ, Π²ΠΊΠ»ΡŽΡ‡Π°Ρ‚ΡŒ Π»ΠΈ Ρ„Π°ΠΉΠ» Π² Android сборку ΠΈΠ»ΠΈ Π½Π΅Ρ‚.

ΠŸΠΎΠΏΡ€ΠΎΠ±ΡƒΠ΅ΠΌ ΠΎΡ€Π³Π°Π½ΠΈΠ·ΠΎΠ²Π°Ρ‚ΡŒ взаимодСйствиС ΠΌΠ΅ΠΆΠ΄Ρƒ Java ΠΈ Unity ΠΊΠΎΠ΄ΠΎΠΌ Π±Π΅Π· использования GameObject Π°Π½Π°Π»ΠΎΠ³ΠΈΡ‡Π½ΠΎ ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π°ΠΌ для iOS, Ρ€Π΅Π°Π»ΠΈΠ·ΠΎΠ²Π°Π² свой UnitySendMessage ΠΈ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ ΠΏΠ΅Ρ€Π΅Π΄Π°Π²Π°Ρ‚ΡŒ ΠΊΠΎΠ»Π±Π΅ΠΊΠΈ ΠΈΠ· C#. Для этого Π½Π°ΠΌ понадобятся AndroidJavaProxy β€” Π‘# классы, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΠΌΡ‹Π΅ ΠΊΠ°ΠΊ Ρ€Π΅Π°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ Java интСрфСйсов. Названия классов ΠΎΡΡ‚Π°Π²Π»ΡŽ Ρ‚Π΅ ΠΆΠ΅, Ρ‡Ρ‚ΠΎ ΠΈΠ· ΠΏΡ€Π΅Π΄Ρ‹Π΄ΡƒΡ‰Π΅ΠΉ ΡΡ‚Π°Ρ‚ΡŒΠΈ. ΠŸΡ€ΠΈ ΠΆΠ΅Π»Π°Π½ΠΈΠΈ ΠΈΡ… ΠΊΠΎΠ΄ ΠΌΠΎΠΆΠ½ΠΎ ΠΎΠ±ΡŠΠ΅Π΄ΠΈΠ½ΠΈΡ‚ΡŒ с ΠΊΠΎΠ΄ΠΎΠΌ ΠΈΠ· ΠΏΠ΅Ρ€Π²ΠΎΠΉ части для ΠΌΡƒΠ»ΡŒΡ‚ΠΈΠΏΠ»Π°Ρ‚Ρ„ΠΎΡ€ΠΌΠ΅Π½Π½ΠΎΠΉ Ρ€Π΅Π°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ.

На сторонС Java ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΠΈΠΌ интСрфСйс для получСния сообщСний ΠΈ класс, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π±ΡƒΠ΄Π΅Ρ‚ Ρ€Π΅Π³ΠΈΡΡ‚Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ, Π° ΠΏΠΎΡ‚ΠΎΠΌ ΠΈ Π΄Π΅Π»Π΅Π³ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Π²Ρ‹Π·ΠΎΠ²Ρ‹ Π²Ρ‹ΡˆΠ΅ΠΎΠΏΠΈΡΠ°Π½Π½ΠΎΠΌΡƒ JavaMessageHandler. ΠŸΠΎΠΏΡƒΡ‚Π½ΠΎ Ρ€Π΅ΡˆΠΈΠΌ Π·Π°Π΄Π°Ρ‡Ρƒ пСрСнаправлСния ΠΏΠΎΡ‚ΠΎΠΊΠΎΠ². Π’Π°ΠΊ ΠΊΠ°ΠΊ Π² ΠΎΡ‚Π»ΠΈΡ‡ΠΈΠ΅ ΠΎΡ‚ iOS, Π½Π° Android Unity создаСт свой ΠΏΠΎΡ‚ΠΎΠΊ, ΠΈΠΌΠ΅ΡŽΡ‰ΠΈΠΉ loop circle, ΠΌΠΎΠΆΠ½ΠΎ ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ android.os.Handler ΠΏΡ€ΠΈ ΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ ΠΈ ΠΏΠ΅Ρ€Π΅Π΄Π°Π²Π°Ρ‚ΡŒ Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ Π΅ΠΌΡƒ.

Π’Π΅ΠΏΠ΅Ρ€ΡŒ Π΄ΠΎΠ±Π°Π²ΠΈΠΌ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ Π²Ρ‹Π·Ρ‹Π²Π°Ρ‚ΡŒ Java Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ с ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ‡Π΅ΠΉ ΠΊΠΎΠ»Π±Π΅ΠΊΠ°, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡ всС Ρ‚ΠΎΡ‚ ΠΆΠ΅ AndroidJavaProxy.

На сторонС Java объявляСм интСрфСйс ΠΊΠΎΠ»Π±Π΅ΠΊΠ°, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ ΠΏΠΎΡ‚ΠΎΠΌ Π±ΡƒΠ΄Π΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ Π²ΠΎ всСх экспортируСмых функциях с ΠΊΠΎΠ»Π±Π΅ΠΊΠΎΠΌ:

Π’ качСствС Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚Π° ΠΊΠΎΠ»Π±Π΅ΠΊΠ° я использовал Json, Ρ‚Π°ΠΊΠΆΠ΅ ΠΊΠ°ΠΊ ΠΈ Π² ΠΏΠ΅Ρ€Π²ΠΎΠΉ части, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ это избавляСт ΠΎΡ‚ нСобходимости ΠΎΠΏΠΈΡΡ‹Π²Π°Ρ‚ΡŒ интСрфСйсы ΠΈ AndroidJavaProxy Π½Π° ΠΊΠ°ΠΆΠ΄Ρ‹ΠΉ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΡ‹ΠΉ Π² ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π΅ Π½Π°Π±ΠΎΡ€ Ρ€Π°Π·Π½ΠΎΡ‚ΠΈΠΏΠ½Ρ‹Ρ… Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚ΠΎΠ². Π’ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ, Π²Π°ΡˆΠ΅ΠΌΡƒ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Ρƒ большС ΠΏΠΎΠ΄ΠΎΠΉΠ΄Π΅Ρ‚ string ΠΈΠ»ΠΈ array. ΠŸΡ€ΠΈΠ²ΠΎΠΆΡƒ ΠΏΡ€ΠΈΠΌΠ΅Ρ€ использования с описаниСм тСстового сСриализуСмого класса Π² качСствС Ρ‚ΠΈΠΏΠ° для ΠΊΠΎΠ»Π±Π΅ΠΊΠ°.

Випичная ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΠ° ΠΏΡ€ΠΈ написании ΠΏΠ»Π°Π³ΠΈΠ½ΠΎΠ² ΠΏΠΎΠ΄ Android для Unity: ΠΎΡ‚Π»Π°Π²Π»ΠΈΠ²Π°Ρ‚ΡŒ ΠΆΠΈΠ·Π½Π΅Π½Π½Ρ‹Π΅ Ρ†ΠΈΠΊΠ»Ρ‹ ΠΈΠ³Ρ€ΠΎΠ²ΠΎΠ³ΠΎ Activity, Π° Ρ‚Π°ΠΊΠΆΠ΅ onActivityResult ΠΈ запуск Application. ΠžΠ±Ρ‹Ρ‡Π½ΠΎ для этого ΠΏΡ€Π΅Π΄Π»Π°Π³Π°ΡŽΡ‚ ΠΎΡ‚Π½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°Ρ‚ΡŒΡΡ ΠΎΡ‚ UnityPlayerActivity ΠΈ ΠΏΠ΅Ρ€Π΅ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΠΈΡ‚ΡŒ класс Ρƒ launch activity Π² манифСстС. Π’ΠΎ ΠΆΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ для Application. Но Π² этой ΡΡ‚Π°Ρ‚ΡŒΠ΅ ΠΌΡ‹ пишСм ΠΏΠ»Π°Π³ΠΈΠ½. Π’Π°ΠΊΠΈΡ… ΠΏΠ»Π°Π³ΠΈΠ½ΠΎΠ² Π² Π±ΠΎΠ»ΡŒΡˆΠΈΡ… ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°Ρ… ΠΌΠΎΠΆΠ΅Ρ‚ Π±Ρ‹Ρ‚ΡŒ нСсколько, наслСдованиС Π½Π΅ ΠΏΠΎΠΌΠΎΠΆΠ΅Ρ‚. НуТно ΠΈΠ½Ρ‚Π΅Π³Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒΡΡ максимально ΠΏΡ€ΠΎΠ·Ρ€Π°Ρ‡Π½ΠΎ Π±Π΅Π· нСобходимости ΠΌΠΎΠ΄ΠΈΡ„ΠΈΠΊΠ°Ρ†ΠΈΠΉ основных классов ΠΈΠ³Ρ€Ρ‹. На ΠΏΠΎΠΌΠΎΡ‰ΡŒ ΠΏΡ€ΠΈΠ΄ΡƒΡ‚ ActivityLifecycleCallbacks ΠΈ ContentProvider.

НС Π·Π°Π±ΡƒΠ΄ΡŒΡ‚Π΅ Π·Π°Ρ€Π΅Π³ΠΈΡΡ‚Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ InitProvider Π² манифСстС (Aar Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ, Π½Π΅ основном):

Π’ΡƒΡ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ Ρ‚ΠΎΡ‚ Ρ„Π°ΠΊΡ‚, Ρ‡Ρ‚ΠΎ Application Π½Π° стартС создаСт всС ΠΎΠ±ΡŠΡΠ²Π»Π΅Π½Π½Ρ‹Π΅ Content Provider. И Ссли Π΄Π°ΠΆΠ΅ ΠΎΠ½ Π½Π΅ прСдоставляСт Π½ΠΈΠΊΠ°ΠΊΠΈΡ… Π΄Π°Π½Π½Ρ‹Ρ…, ΠΊΠ°ΠΊΠΈΠ΅ Π΄ΠΎΠ»ΠΆΠ΅Π½ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Ρ‚ΡŒ Π½ΠΎΡ€ΠΌΠ°Π»ΡŒΠ½Ρ‹ΠΉ Content Provider, Π² ΠΌΠ΅Ρ‚ΠΎΠ΄Π΅ onCreate ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ Ρ‡Ρ‚ΠΎ-Ρ‚ΠΎ, Ρ‡Ρ‚ΠΎ ΠΎΠ±Ρ‹Ρ‡Π½ΠΎ дСлаСтся Π½Π° стартС Application, Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€ Π·Π°Ρ€Π΅Π³ΠΈΡΡ‚Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ наш ActivityLifecycleCallbacks. А ΠΎΠ½ ΡƒΠΆΠ΅ Π±ΡƒΠ΄Π΅Ρ‚ ΠΏΠΎΠ»ΡƒΡ‡Π°Ρ‚ΡŒ события onActivityCreated, onActivityStarted, onActivityResumed, onActivityPaused, onActivityStopped, onActivitySaveInstanceState ΠΈ onActivityDestroyed. ΠŸΡ€Π°Π²Π΄Π° события Π±ΡƒΠ΄ΡƒΡ‚ ΠΈΠ΄Ρ‚ΠΈ ΠΎΡ‚ всСх Π°ΠΊΡ‚ΠΈΠ²ΠΈΡ‚ΠΈ, Π½ΠΎ ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΠΈΡ‚ΡŒ основноС ΠΈΠ· Π½ΠΈΡ… ΠΈ Ρ€Π΅Π°Π³ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π½Π° Π½Π΅Π³ΠΎ Π½ΠΈΡ‡Π΅Π³ΠΎ Π½Π΅ стоит:

НС Ρ…Π²Π°Ρ‚Π°Π΅Ρ‚ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ onActivityResult, ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠ΅ ΠΎΠ±Ρ‹Ρ‡Π½ΠΎ трСбуСтся для Π²ΠΎΠ·Π²Ρ€Π°Ρ‚Π° Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Π° ΠΎΡ‚ ΠΏΠΎΠΊΠ°Π·Π° Π½Π°Ρ‚ΠΈΠ²Π½ΠΎΠ³ΠΎ экрана ΠΏΠΎΠ²Π΅Ρ€Ρ… ΠΈΠ³Ρ€Ρ‹. ΠΠ°ΠΏΡ€ΡΠΌΡƒΡŽ этот Π²Ρ‹Π·ΠΎΠ² ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ, ΠΊ соТалСнию нСльзя. Но ΠΌΠΎΠΆΠ½ΠΎ ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ Π½ΠΎΠ²ΠΎΠ΅ Activity, ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠ΅ ΠΏΠΎΠΊΠ°ΠΆΠ΅Ρ‚ Ρ‚Ρ€Π΅Π±ΡƒΠ΅ΠΌΠΎΠ΅ Activity, ΠΏΠΎΡ‚ΠΎΠΌ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ ΠΎΡ‚ Π½Π΅Π³ΠΎ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚, Π²Π΅Ρ€Π½Π΅Ρ‚ Π½Π°ΠΌ ΠΈ Ρ„ΠΈΠ½ΠΈΡˆΠΈΡ€ΡƒΠ΅Ρ‚. Π“Π»Π°Π²Π½ΠΎΠ΅ ΠΈΡΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ Π΅Π³ΠΎ ΠΈΠ· истории ΠΈ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ ΠΏΡ€ΠΎΠ·Ρ€Π°Ρ‡Π½Ρ‹ΠΌ, ΡƒΠΊΠ°Π·Π°Π² Ρ‚Π΅ΠΌΡƒ Π² манифСстС, Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΏΡ€ΠΈ ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΈΠΈ Π½Π΅ мСлькал Π±Π΅Π»Ρ‹ΠΉ экран:

Π’Π°ΠΊΠΈΠΌ ΠΎΠ±Ρ€Π°Π·ΠΎΠΌ ΠΌΠΎΠΆΠ½ΠΎ Ρ€Π΅Π°Π»ΠΈΠ·ΠΎΠ²Π°Ρ‚ΡŒ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΡ‹ΠΉ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π», Π½Π΅ прибСгая ΠΊ ΠΌΠΎΠ΄ΠΈΡ„ΠΈΠΊΠ°Ρ†ΠΈΠΈ основных классов Unity Java, ΠΈ Π°ΠΊΠΊΡƒΡ€Π°Ρ‚Π½ΠΎ ΡƒΠΏΠ°ΠΊΠΎΠ²Π°Ρ‚ΡŒ манифСст с ΠΊΠΎΠ΄ΠΎΠΌ ΠΈ рСсурсами Π² Aar Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΡƒ. Но Ρ‡Ρ‚ΠΎ Π΄Π΅Π»Π°Ρ‚ΡŒ с ΠΏΠ°ΠΊΠ΅Ρ‚Π°ΠΌΠΈ зависимостСй ΠΈΠ· maven Ρ€Π΅ΠΏΠΎΠ·ΠΈΡ‚ΠΎΡ€ΠΈΠ΅Π², ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ Ρ‚Ρ€Π΅Π±ΡƒΡŽΡ‚ΡΡ Π½Π°ΡˆΠ΅ΠΌΡƒ ΠΏΠ»Π°Π³ΠΈΠ½Ρƒ? Unity Π³Π΅Π½Π΅Ρ€ΠΈΡ€ΡƒΠ΅Ρ‚ gradle ΠΏΡ€ΠΎΠ΅ΠΊΡ‚, Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ всС java Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° ΡΠΊΠ»Π°Π΄Ρ‹Π²Π°ΡŽΡ‚ΡΡ Π² libs экспортируСмого ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° ΠΈ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π°ΡŽΡ‚ΡΡ локально. Π”ΡƒΠ±Π»ΠΈΠΊΠ°Ρ‚ΠΎΠ² Π±Ρ‹Ρ‚ΡŒ Π½Π΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ. Π”Ρ€ΡƒΠ³ΠΈΠ΅ зависимости Π°Π²Ρ‚ΠΎΠΌΠ°Ρ‚ΠΎΠΌ Π²ΠΊΠ»ΡŽΡ‡Π΅Π½Ρ‹ Π½Π΅ Π±ΡƒΠ΄ΡƒΡ‚. ΠŸΠΎΠ»ΠΎΠΆΠΈΡ‚ΡŒ зависимости рядом с скомпилированным Aar Π½Π΅ всСгда Ρ…ΠΎΡ€ΠΎΡˆΠ°Ρ идСя: Ρ‡Π°Ρ‰Π΅ всСго эти ΠΆΠ΅ зависимости Π½ΡƒΠΆΠ½Ρ‹ ΠΈ Π΄Ρ€ΡƒΠ³ΠΈΠΌ Unity ΠΏΠ»Π°Π³ΠΈΠ½Π°ΠΌ. И Ссли ΠΎΠ½ΠΈ ΠΏΠΎΠ»ΠΎΠΆΠΈΠ»ΠΈ Ρ‚ΠΎΠΆΠ΅ свою Π²Π΅Ρ€ΡΠΈΡŽ Π² unitypackage, ΠΏΡ€ΠΎΠΈΠ·ΠΎΠΉΠ΄Π΅Ρ‚ ΠΊΠΎΠ½Ρ„Π»ΠΈΠΊΡ‚ вСрсий, gradle ΠΏΡ€ΠΈ сборкС ругнСтся Π½Π° Π΄ΡƒΠ±Π»ΠΈΠΊΠ°Ρ‚ классов. Π’Π°ΠΊΠΆΠ΅ зависимости зависят ΠΎΡ‚ Π΄Ρ€ΡƒΠ³ΠΈΡ… ΠΏΠ°ΠΊΠ΅Ρ‚ΠΎΠ², ΠΈ Π²Ρ€ΡƒΡ‡Π½ΡƒΡŽ ΡΠΎΡΡ‚Π°Π²ΠΈΡ‚ΡŒ эту Ρ†Π΅ΠΏΠΎΡ‡ΠΊΡƒ зависимостСй, Π²Ρ‹ΠΊΠ°Ρ‡Π°Π² ΠΈΠ· maven-рСпозитория всС, Ρ‡Ρ‚ΠΎ Π½ΡƒΠΆΠ½ΠΎ β€” Π·Π°Π΄Π°Ρ‡Π° Π½Π΅ такая ΡƒΠΆ простая.

Π˜ΡΠΊΠ°Ρ‚ΡŒ Π² ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π΅ Π΄ΡƒΠ±Π»ΠΈΠΊΠ°Ρ‚Ρ‹ Ρ‚ΠΎΠΆΠ΅ ΡƒΡ‚ΠΎΠΌΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ. Π₯очСтся Π°Π²Ρ‚ΠΎΠΌΠ°Ρ‚ΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ Ρ€Π΅ΡˆΠ΅Π½ΠΈΡ, ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠ΅ само скачаСт Π½ΡƒΠΆΠ½Ρ‹Π΅ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ Π½ΡƒΠΆΠ½Ρ‹Ρ… вСрсий Π² ΠΏΡ€ΠΎΠ΅ΠΊΡ‚, удаляя Π΄ΡƒΠ±Π»ΠΈΠΊΠ°Ρ‚Ρ‹. И Ρ‚Π°ΠΊΠΎΠ΅ Ρ€Π΅ΡˆΠ΅Π½ΠΈΠ΅ Π΅ΡΡ‚ΡŒ. Π”Π°Π½Π½Ρ‹ΠΉ ΠΏΠ°ΠΊΠ΅Ρ‚ ΠΌΠΎΠΆΠ½ΠΎ ΡΠΊΠ°Ρ‡Π°Ρ‚ΡŒ ΡΠ°ΠΌΠΎΡΡ‚ΠΎΡΡ‚Π΅Π»ΡŒΠ½ΠΎ, Π° Ρ‚Π°ΠΊΠΆΠ΅ ΠΎΠ½ поставляСтся вмСстС с Google Play Services ΠΈ Firebase. ИдСя Π² Ρ‚ΠΎΠΌ, Ρ‡Ρ‚ΠΎ Π² Unity ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π΅ создаСм xml Ρ„Π°ΠΉΠ»Ρ‹ со списком зависимостСй, Ρ‚Ρ€Π΅Π±ΡƒΠ΅ΠΌΡ‹Ρ… ΠΏΠ»Π°Π³ΠΈΠ½Π°ΠΌ ΠΏΠΎ синтаксису, схоТСму с ΠΎΠΏΡ€Π΅Π΄Π΅Π»Π΅Π½ΠΈΠ΅ΠΌ Π² build.gradle (с ΡƒΠΊΠ°Π·Π°Π½ΠΈΠ΅ΠΌ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡŒΠ½Ρ‹Ρ… вСрсий):

Π”Π°Π»Π΅Π΅ послС установки ΠΈΠ»ΠΈ измСнСния зависимостСй Π² ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π΅ Π²Ρ‹Π±ΠΈΡ€Π°Π΅ΠΌ Π² мСню Unity Ρ€Π΅Π΄Π°ΠΊΡ‚ΠΎΡ€Π° Assets β†’ Play Services Resolver β†’ Android Resolver β†’ Resolve ΠΈ вуаля! Π£Ρ‚ΠΈΠ»ΠΈΡ‚Π° просканируСт xml объявлСния, создаст Π³Ρ€Π°Ρ„ зависимостСй ΠΈ всС Π½ΡƒΠΆΠ½Ρ‹Π΅ ΠΏΠ°ΠΊΠ΅Ρ‚Ρ‹ зависимостСй Π½ΡƒΠΆΠ½Ρ‹Ρ… вСрсий скачаСт ΠΈΠ· maven Ρ€Π΅ΠΏΠΎΠ·ΠΈΡ‚ΠΎΡ€ΠΈΠ΅Π² Π² Assets/Plugins/Android. ΠŸΡ€ΠΈΡ‡Π΅ΠΌ ΠΎΠ½Π° ΠΎΡ‚ΠΌΠ΅Ρ‡Π°Π΅Ρ‚ Π² ΡΠΏΠ΅Ρ†ΠΈΠ°Π»ΡŒΠ½ΠΎΠΌ Ρ„Π°ΠΉΠ»Π΅ скачанноС ΠΈ Π² ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ Ρ€Π°Π· замСняСт Π΅Π³ΠΎ Π½ΠΎΠ²Ρ‹ΠΌΠΈ вСрсиями, Π° Ρ‚Π΅ Ρ„Π°ΠΉΠ»Ρ‹, Ρ‡Ρ‚ΠΎ ΠΏΠΎΠ»ΠΎΠΆΠΈΠ»ΠΈ ΠΌΡ‹, ΠΎΠ½Π° Ρ‚Ρ€ΠΎΠ³Π°Ρ‚ΡŒ Π½Π΅ Π±ΡƒΠ΄Π΅Ρ‚. Π’Π°ΠΊΠΆΠ΅ Π΅ΡΡ‚ΡŒ ΠΎΠΊΠ½ΠΎ настроСк, Π³Π΄Π΅ ΠΌΠΎΠΆΠ½ΠΎ Π²ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ автоматичСскоС Ρ€Π°Π·Ρ€Π΅ΡˆΠ΅Π½ΠΈΠ΅ зависимостСй, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π½Π΅ Π½Π°ΠΆΠΈΠΌΠ°Ρ‚ΡŒ Resolve Ρ‡Π΅Ρ€Π΅Π· мСню, ΠΈ ΠΌΠ½ΠΎΠ³ΠΎ Π΄Ρ€ΡƒΠ³ΠΈΡ… ΠΎΠΏΡ†ΠΈΠΉ. Для Ρ€Π°Π±ΠΎΡ‚Ρ‹ трСбуСтся Android Sdk, установлСнный Π½Π° ΠΊΠΎΠΌΠΏΡŒΡŽΡ‚Π΅Ρ€Π΅ вмСстС с Unity ΠΈ Π²Ρ‹Π±Ρ€Π°Π½Π½Ρ‹ΠΉ target β€” Android. Π’ Ρ‚ΠΎΠΌ ΠΆΠ΅ Ρ„Π°ΠΉΠ»Π΅ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΈΡΠ°Ρ‚ΡŒ CocoaPods зависимости для iOS Π±ΠΈΠ»Π΄ΠΎΠ², ΠΈ Π² настройках Π·Π°Π΄Π°Ρ‚ΡŒ, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Unity Π³Π΅Π½Π΅Ρ€ΠΈΡ€ΠΎΠ²Π°Π»Π° xcworkspace с Π²ΠΊΠ»ΡŽΡ‡Π΅Π½Π½Ρ‹ΠΌΠΈ зависимостями для основного ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° XCode.

Unity ΠΎΡ‚Π½ΠΎΡΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ Π½Π΅Π΄Π°Π²Π½ΠΎ стала ΠΏΠΎΠ»Π½ΠΎΡ†Π΅Π½Π½ΠΎ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΈΠ²Π°Ρ‚ΡŒ gradle сборщик для Android, Π° ADT объявила ΠΊΠ°ΠΊ legacy. Появилась Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ ΡΠΎΠ·Π΄Π°Π²Π°Ρ‚ΡŒ template для gradle ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΈ экспортируСмого ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°, полноцСнная ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Aar ΠΈ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Ρ… Π² манифСстах, слияниС манифСстов. Но ΠΏΠ»Π°Π³ΠΈΠ½Ρ‹ сторонних sdk Π΅Ρ‰Π΅ Π½Π΅ успСли Π°Π΄Π°ΠΏΡ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒΡΡ ΠΏΠΎΠ΄ эти измСнСния ΠΈ Π½Π΅ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡŽΡ‚ Ρ‚Π΅ возмоТности, Ρ‡Ρ‚ΠΎ прСдоставляСт Ρ€Π΅Π΄Π°ΠΊΡ‚ΠΎΡ€. ΠŸΠΎΡΡ‚ΠΎΠΌΡƒ ΠΌΠΎΠΉ совСт, Π»ΡƒΡ‡ΡˆΠ΅ ΠΌΠΎΠ΄ΠΈΡ„ΠΈΡ†ΠΈΡ€ΡƒΠΉΡ‚Π΅ ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΡƒΠ΅ΠΌΡƒΡŽ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΡƒ ΠΏΠΎΠ΄ соврСмСнныС Ρ€Π΅Π°Π»ΠΈΠΈ: ΡƒΠ΄Π°Π»ΠΈΡ‚Π΅ зависимости ΠΈ ΠΎΠ±ΡŠΡΠ²ΠΈΡ‚Π΅ ΠΈΡ… Ρ‡Π΅Ρ€Π΅Π· xml для Unity Jar Resolver, скомпилируйтС вСсь java ΠΊΠΎΠ΄ ΠΈ рСсурсы Π² Aar. Π˜Π½Π°Ρ‡Π΅ каТдая ΠΏΠΎΡΠ»Π΅Π΄ΡƒΡŽΡ‰Π°Ρ интСграция Π±ΡƒΠ΄Π΅Ρ‚ Π»ΠΎΠΌΠ°Ρ‚ΡŒ ΠΏΡ€Π΅Π΄Ρ‹Π΄ΡƒΡ‰ΠΈΠ΅ ΠΈ ΠΎΡ‚Π½ΠΈΠΌΠ°Ρ‚ΡŒ всС большС Π²Ρ€Π΅ΠΌΠ΅Π½ΠΈ.

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

Unity β€” Enable Multidex ΠΈΠ»ΠΈ слишком ΠΌΠ½ΠΎΠ³ΠΎ ΠΌΠ΅Ρ‚ΠΎΠ΄ΠΎΠ²

Π‘ Ρ‡Π΅Π³ΠΎ всС Π½Π°Ρ‡Π°Π»ΠΎΡΡŒ

ВсСм ΠΏΡ€ΠΈΠ²Π΅Ρ‚. На ΠΎΠΏΡ€Π΅Π΄Π΅Π»Π΅Π½Π½ΠΎΠΌ этапС Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠΈ ΠΈΠ³Ρ€Ρ‹ ΠΏΠΎΠ΄ Android Π½Π° Π΄Π²ΠΈΠΆΠΊΠ΅ Unity я столкнулся с ΠΎΠ΄Π½ΠΎΠΉ ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΠΎΠΉ ΠΏΡ€ΠΈ Π±ΠΈΠ»Π΄Π΅. ПослС добавлСния Π² ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ Ρ‚Π°ΠΊΠΈΡ… ΠΏΠ»Π°Π³ΠΈΠ½ΠΎΠ² ΠΊΠ°ΠΊ Appodeal ΠΈ Google Play Games количСство ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΠΌΡ‹Ρ… ΠΌΠ΅Ρ‚ΠΎΠ΄ΠΎΠ² прСвысило 65K ΠΈ Π²ΠΎ врСмя Π±ΠΈΠ»Π΄Π° появилась ΡΠ»Π΅Π΄ΡƒΡŽΡ‰Π°Ρ ошибка:

ΠŸΠΎΡ‡ΠΈΡ‚Π°Π² Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΡŽ Appodeal, понял Ρ‡Ρ‚ΠΎ Π½Π°Π΄ΠΎ Π²ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ Multidex. РСшил это ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ. На сайтС Π±Ρ‹Π»Π° ссылка с инструкциСй для Android Studio. А ΠΌΡ‹ Ρ‚ΠΎ с Π²Π°ΠΌΠΈ Π½Π° Unity, Ρ‡Ρ‚ΠΎ ΠΆΠ΅ Π΄Π΅Π»Π°Ρ‚ΡŒ?

А всС довольно просто Π½Π°Π΄ΠΎ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ всСго Ρ‚Ρ€ΠΈ дСйствия:

Π’ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ систСму сборки Gradle

Π§Ρ‚ΠΎΠ±Ρ‹ Π² своСм ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π΅ Π½Π° Android Π²ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ систСму Gradle Π² Unity Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΠΌ ΠΏΠ°Ρ€Ρƒ дСйствий

ИзмСнСниС настроСк Gradle

1. Π§Ρ‚ΠΎΠ±Ρ‹ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡ‚ΡŒ настройки Gradle, Π²Π°ΠΌ сначала Π½ΡƒΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ Ρ„Π°ΠΉΠ» настроСк Gradle, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ располоТСн Π² ΠΏΠ°ΠΏΠΊΠ΅ (Assets/Plugins/Android/mainTemplate.gradle). Если Ρ„Π°ΠΉΠ»Π° mainTemplate.gradle скачайтС ΠΏΠΎ ссылкС ΠΈ Π²ΡΡ‚Π°Π²ΡŒΡ‚Π΅ ΠΏΠΎ адрСсу Assets/Plugins/Android/:

2. Если Ρ„Π°ΠΉΠ» Ρƒ вас ΡƒΠΆΠ΅ Π΅ΡΡ‚ΡŒ, добавляСм строку multiDexEnabled true Π² ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ defaultConfig

3. Если ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡŒΠ½Ρ‹ΠΉ ΡƒΡ€ΠΎΠ²Π΅Π½ΡŒ API Android Ρ€Π°Π²Π΅Π½ 20 ΠΈΠ»ΠΈ Π½ΠΈΠΆΠ΅, Π΄ΠΎΠ±Π°Π²ΡŒΡ‚Π΅ эту строку compile β€˜com.android.support:multidex:1.0.1’

4. Π—Π°ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚ΠΈΡ€ΡƒΠ΅ΠΌ ΠΈΠ»ΠΈ ΡƒΠ΄Π°Π»ΠΈΠΌ строки:

ΠžΠΊΠΎΠ½Ρ‡Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹ΠΉ Π²ΠΈΠ΄ Ρ„Π°ΠΉΠ»Π°:

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅

Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Multidex

Если ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡŒΠ½Ρ‹ΠΉ ΡƒΡ€ΠΎΠ²Π΅Π½ΡŒ API Android, установлСнный Π½Π° 20 ΠΈΠ»ΠΈ Π½ΠΈΠΆΠ΅.

ΠžΠ±Π½ΠΎΠ²ΠΈΡ‚Π΅ Ρ„Π°ΠΉΠ» манифСста, располоТСнный Π² Assets/Plugins/Android/AndroidManifest.XML. Если Ρƒ вас Π½Π΅Ρ‚ этого Ρ„Π°ΠΉΠ»Π°, Π²Π°ΠΌ придСтся Π΅Π³ΠΎ ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ. Π’Ρ‹ ΠΌΠΎΠΆΠ΅Ρ‚Π΅ Π½Π°ΠΉΡ‚ΠΈ AndroidManifest ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ.xml Π² мСстС установки Unity. Но Π²Π°ΠΌ Ρ‚Π°ΠΊΠΆΠ΅ придСтся Π²Ρ€ΡƒΡ‡Π½ΡƒΡŽ ΠΏΡ€ΠΈΠΌΠ΅Π½ΠΈΡ‚ΡŒ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° вашСго прилоТСния: имя ΠΏΠ°ΠΊΠ΅Ρ‚Π°, Ρ€Π°Π·Ρ€Π΅ΡˆΠ΅Π½ΠΈΡ, ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΈ ΠΈ Π΄Ρ€ΡƒΠ³ΡƒΡŽ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡŽ.

Если Π²Ρ‹ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Ρ‡Ρ‚ΠΎ создали Π½ΠΎΠ²Ρ‹ΠΉ Ρ„Π°ΠΉΠ» манифСста ΠΈΠ»ΠΈ Ρƒ вас ΡƒΠΆΠ΅ Π±Ρ‹Π» ΠΎΠ½, Π²Ρ‹ просто добавляСтС этот ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€(android:name) ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΌ ΠΎΠ±Ρ€Π°Π·ΠΎΠΌ:

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅

На этом всС. Ошибка исчСзнСт, ΠΈ Π²Ρ‹ спокойно сбилдитС свой ΠΏΡ€ΠΎΠ΅ΠΊΡ‚.

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

Android Player settings

This page details the Player settings specific to the Android platform. For a description of the general Player settings, see the Player settings.

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅Android Player settings

Documentation for the properties is grouped according to their respective sections in the Player UI (User Interface) Allows a user to interact with your application. Unity currently supports three UI systems. More info
See in Glossary :

Resolution and Presentation

Use the Resolution and Presentation section to customize aspects of the screen’s appearance.

Other Resolution and Presentation properties are grouped under these sections:

Resolution Scaling

Supported Aspect Ratio

Set the Aspect Ratio Mode for the device. You can choose from Legacy Wide Screen (1.86), Native Aspect Ratio, and Custom. When you choose Custom, the Up To field appears.

Set a custom maximum screen width with the Up To property. This property is only available when Aspect Ratio Mode is set to Custom.

Orientation

Choose the game’s screen orientation from the Default Orientation drop-down menu:

SettingFunction
PortraitHome button appears at the bottom.
Portrait Upside DownHome button appears at the top.
Landscape LeftHome button appears on the right side.
Landscape RightHome button appears on the left side.
Auto RotationAllow the screen to automatically rotate to any of the orientations specified by the Allowed Orientations for Auto Rotation settings. This is the default.

Note: This setting is shared between iOS Apple’s mobile operating system. More info
See in Glossary and Android devices.

When you set the orientation to Auto Rotation, the Allowed Orientations for Auto Rotation section appears.

Allowed Orientations for Auto Rotation

This section is only visible when Default Orientation is set to Auto Rotation.

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅Allowed Orientations for Auto Rotation Player settings for the Android platform

Because Auto Rotation changes screen orientation to match the device, you may want to limit the screen orientations allowed (for example, locking a device to landscape).

Enable each orientation you want to allow by checking its box in this section:

SettingFunction
PortraitAllow portrait orientation.
Portrait Upside DownAllow portrait upside-down orientation.
Landscape RightAllow landscape right orientation (home button on the left side).
Landscape LeftAllow landscape left orientation (home button is on the right side).

Other

Splash Image

Above the common Splash Screen settings, you can use the Virtual Reality Splash Image setting to specify a custom splash image for Virtual Reality A system that immerses users in an artificial 3D world of realistic images and sounds, using a headset and motion tracking. More info
See in Glossary displays.

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅Splash Settings for the Android platform Player

Below the common Splash Screen settings, you can set up an Android-specific Static Splash Image.

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅Use Storyboard for Launch Screen on the Android Player platform

Use the Android Splash Screen property to specify the texture that should be used for the Android splash screen. The standard size for the splash screen image is 320×480.

Choose how you want Unity to scale the splash image to fit the device’s screen from the Splash Scaling drop-down menu. The options are:

Other Settings

This section allows you to customize a range of options organized into the following groups:

Rendering

Use these settings to customize how Unity renders your game for the Android platform.

Vulkan Settings

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅Vulkan Player settings for the Android platform

PropertyFunction
SRGB Write ModeEnable this option to allow Graphics.SetSRGBWrite() on Vulkan renderer to toggle the sRGB write mode during the frame. Enabling this has a negative impact on performance.
Number of swapchain buffersSet this option to 2 for double-bufferin, or 3 for triple-buffering. Double-buffering might have a negative impact on performance.
Acquire swaichain image late as possibleEnable this option to acquire the backbuffer image right before the image is presented. This might improve performance if double-buffering is selected, but should otherwise be avoided on Android because it introduces additional memory bandwidth costs.
Apply display rotation during renderingEnable this to perform all rendering in the native orientation of the display. This has a performance benefit on many devices. For more information, see documentation on Vulkan swapchain pre-rotation.

Identification

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅Identification settings for the Android platform

PropertyFunction
Package NameSet the application ID, which uniquely identifies your app on the device and in Google Play Store. The basic structure of the identifier is com.CompanyName.AppName, and can be chosen arbitrarily. This setting is shared between iOS and Android.
VersionEnter the build version number of the bundle, which identifies an iteration (released or unreleased) of the bundle. The version is specified in the common format of a string containing numbers separated by dots (eg, 4.3.2). (Shared between iOS and Android.)
Bundle Version CodeAn internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute. The value must be set as an integer, such as β€œ100”. You can define it however you want, as long as each successive version has a higher number.

For example, it could be a build number. Or you could translate a version number in β€œx.y” format to an integer by encoding the β€œx” and β€œy” separately in the lower and upper 16 bits. Or you could simply increase the number by one each time a new version is released.

Keep this number under 100000 if Split APKs by target architecture is enabled. Each APK must have a unique version code so Unity adds 100000 to the number for ARMv7, and 200000 for ARM64.

Minimum API LevelMinimum Android version (API level) required to run the application.
Target API LevelTarget Android version (API level) against which to compile the application.

Configuration

API Compatibility Level

Script Compilation

Optimization

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅Optimization settings for the Android platform

SettingFunction
Prebake Collision A collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a Rigidbody component and is in motion. More info
See in Glossary Meshes
Enable this option to add collision data to Meshes at build time.
Keep Loaded Shaders AliveEnable this option to prevent shaders from being unloaded.
Preloaded AssetsSet an array of Assets for the player to load on startup.
To add new Assets, increase the value of the Size property and then set a reference to the Asset to load in the new Element box that appears.
Strip Engine Code (IL2CPP only)Specify whether the Unity Linker tool removes code for Unity Engine features that your Project doesn’t use.
Managed Stripping LevelDefines how aggressively Unity strips unused managed (C#) code.
When Unity builds your game or application, the Unity Linker process can strip unused code from the managed dynamically linked libraries used in the project. Stripping code can make the resulting executable significantly smaller, but can sometimes mistakenly remove code that is actually used. This setting allows you to choose how aggressively Unity should remove unused code.
Disabled (Mono only)Do not strip any code. (Managed code stripping is always enabled when using IL2CPP.)
NormalRemove unreachable managed code to reduce build size and Mono/IL2CPP build times.
Aggressive (Experimental)Remove code more aggressively than under the Normal option. Code size is further reduced, but this additional reduction may have side effects. For example, some methods may no longer be visible in the debugger and code accessed through reflection can be stripped. You can create a custom link.xml file to preserve specific classes and methods. See Managed bytecode stripping with IL2CPP for more information.
Enable Internal profiler A window that helps you to optimize your game. It shows how much time is spent in the various areas of your game. For example, it can report the percentage of time spent rendering, animating, or in your game logic. More info
See in Glossary (Deprecated)
Enable this option to get the profiler data from your device in the Android SDK’s adblogcat output while testing your projects. This is only available in development builds.
Script Call OptimizationChoose how to optionally disable exception handling for a speed boost at runtime. See iOS Optimization for details.
Slow and SafeUse full exception handling (with some performance impact on the device when using the Mono scripting backend).
Fast but no ExceptionsNo data provided for exceptions on the device (the game runs faster when using the Mono scripting backend).
Note: If you use this option with the IL2CPP Scripting Backend it won’t impact performance; however, using it can avoid undefined behavior on release builds.
Vertex CompressionSet vertex compression per channel. For example, you can enable compression for everything except positions and lightmap UVs. Whole Mesh The main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary compression set per imported object overrides where vertex compression is set on objects. Everything else obeys these vertex compression settings.
Optimize Mesh DataEnable this option to remove any data from Meshes that is not required by the Material applied to them (such as tangents, normals, colors, and UVs).

Logging

Select what type of logging to allow in specific contexts.

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅Logging settings for Android platform

Legacy

Enable the Clamp BlendShapes (Deprecated) option to clamp the range of blend shape weights in SkinnedMeshRenderers.

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅Legacy settings for the Android platform

Publishing Settings

Use the Publishing Settings to configure how Unity builds your Android app. To open the Publishing Settings, go to Edit > Project Settings, select Player, select the Android icon, and open the Publishing Settings panel.

This section describes the different parts of the Publishing Settings panel and what they do. These include:

Project Keystore
Project Key
Build The process of compiling your project into a format that is ready to run on a specific platform or platforms. More info
See in Glossary
Minify
Split Application Binary

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅Android publishing panel

Note: For security reasons, Unity doesn’t save your Keystore An Android system that lets you store cryptographic key entries for enhanced device security. More info
See in Glossary or Project Key passwords.

Use the Keystore Manager window to create, configure and load your keys and keystores. You can load existing keystores and keys from either the Keystore Manager or the main Android Publishing panel. If you choose to load these from inside the Keystore Manager, Unity automatically fills the Project Keystore and Project Key fields.
For further information see documentation on the Keystore Manager.

Project Keystore

A keystore is a container that holds signing keys for application security. For details, see Android developer documentation: Android keystore system.

Use the Project Keystore settings to choose which keystore to use for the open project. When you load a keystore, Unity loads all of the keys in that keystore. To load and use an existing keystore in your open project:

If you don’t have an existing keystore, leave Custom Keystore disabled.

Unity uses a debug keystore to sign your application. A debug keystore is a working keystore. It allows you to sign the application and to test it locally. However, the app store will decline apps signed in this way. This is because the app store is unable to verify the validity and ownership of the application using a debug keystore.

PropertyDescription
Custom KeystoreEnable Custom Keystore to load and use an existing Keystore.
SelectWhen Custom Keystore is enabled, use this to select the keystore you want to use. The keystores below the partition in the Select dropdown are stored in a predefined dedicated location. For more details, see Choosing your keystore location.
PathYou do not need to enter your keystore path. Unity provides this based on the keystore you choose.
PasswordEnter your keystore password to load your chosen keystore.

Project Key

When you load a keystore, Unity loads all of the keys in that keystore. Use the Project Key settings to choose one key from that keystore to use as the active key for the open project.

PropertyDescription
AliasSelect the key you want to use for the open project.
PasswordEnter your key Password.

Build

By default, Unity builds your application with the Android manifests, Gradle An Android build system that automates several build processes. This automation means that many common build errors are less likely to occur. More info
See in Glossary templates and Proguard files provided with the Unity installation. Use the Build section of the Android Publishing Settings to change these.

To use a custom Android manifest, Gradle template or Proguard file:

The settings in the Build section only apply to the build process for the current project.

PropertyDescription
Custom Main ManifestCustomisable version of the Android LibraryManifest.xml file. This file contains important metadata about your Android application. For further information about the responsibilities of the Main/Library Manifest see documentation on Android Manifest.
Custom Launcher ManifestCustomisable version of the Android LauncherManifest.xml file. This file contains important metadata about your Android application’s launcher. For further information about the responsibilities of the Launcher Manifest see documentation on Android Manifest.
Custom Main Gradle TemplateCustomisable version of the mainTemplate.gradle file. This file contains information on how to build your Android application as a library. For further information see documentation on Providing a custom Gradle Template.
Custom Launcher Gradle TemplateCustomisable version of the launcherTemplate.gradle_ file. This file contains instructions on how to build your Android application. For further information see documentation on build.gradle templates.
Custom Base Gradle TemplateCustomisable version of the baseProjectTemplate.gradle file. This file contains configuration that is shared between all other templates and Gradle projects. For further information see documentation on build.gradle templates.
Custom Gradle Properties TemplateCustomisable version of the gradle.properties file. This file contains configuration settings for the Gradle build environment. This includes:
— The JVM (Java Virtual Machine) memory configuration.
— A property to allow Gradle to build using multiple JVMs.
— A property for choosing the tool to do the minification.
— A property to not compress native libs when building an app bundle.
Custom Proguard FileCustomisable version of the proguard.txt file. This file contains configuration settings for the minification process. If minification removes some Java code which should be kept, you should add a rule to keep that code in this file. For further information see documentation on Minification.

Minify

Minification is a process which shrinks, obfuscates and optimises the code in your application. It can reduce the code size and make the code harder to disassemble. Use the Minify settings to define when and how Unity should apply minification to your build.

In most cases, it’s good practice to only apply minification to release builds, and not debug builds. This is because minification takes time, and can make the builds slower. It can also make debugging more complicated due to the optimisation that the code undergoes.

The settings in the Minify section only apply to the build process for the current project.

PropertyDescription
Use R8By default, Unity uses Proguard for minification. Enable this checkbox to use R8 instead.
ReleaseEnable this checkbox if you want Unity to minify your application’s code in release builds.
DebugEnable this checkbox if you want Unity to minify your application’s code in debug builds.

Split Application Binary

Enable the Split Application Binary option to split your output package into main (APK) and expansion (OBB) packages. The Google Play Store requires this if you want to publish applications larger than 100 MB.

XR Settings

unity minify Ρ‡Ρ‚ΠΎ Ρ‚Π°ΠΊΠΎΠ΅XR Settings for the Android Player

SettingFunction
Virtual Reality SupportedEnable this if your application is a virtual reality application, then add the required VR SDKs to the list.
Virtual Reality SDKsAdd and remove Virtual Reality SDKs from the list. This list is only available when the Virtual Reality Supported is enabled.
To add an SDK to the list, click the plus (+) button.
To remove an SDK from the list, select it and then click the minus (-) button.
Some of the SDKs provide extra settings that appear here. For details, see XR SDKs.
Stereo Rendering ModeChoose how you want to render for a virtual reality device.
Multi PassThis is the normal rendering mode. Unity renders the Scene A Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary twice: first to render the left-eye image; and then again for the right-eye image.
Single Pass Multiview or Instanced (Preview)Render both eye images at the same time into one packed Render Texture. This means that the whole Scene is only rendered once, which significantly reduces CPU processing time.

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ

Π’Π°Ρˆ адрСс email Π½Π΅ Π±ΡƒΠ΄Π΅Ρ‚ ΠΎΠΏΡƒΠ±Π»ΠΈΠΊΠΎΠ²Π°Π½. ΠžΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ поля ΠΏΠΎΠΌΠ΅Ρ‡Π΅Π½Ρ‹ *