1
\$\begingroup\$

Is there a way to build an apk faster? (by disabling some shader compilation, for example Hidden/Post FX/Uber Shader takes most of the build time)

p.s. Yes I know about Unity Remote and use it - this time I need exactly Build and Run.

\$\endgroup\$
3
  • \$\begingroup\$ Shaders only need to be compiled when they change. If you make multiple builds in a row, without making any changes to materials that might cause a shader to compile differently, and you don’t change targets to, for example, standalone PC, or clear the library, then the shader compilation is not something you need to worry about. \$\endgroup\$
    – Ed Marty
    Feb 24, 2019 at 2:16
  • \$\begingroup\$ Indeed! It takes almost no time when I do little tweaks. Thanks! \$\endgroup\$ Feb 24, 2019 at 7:53
  • \$\begingroup\$ I'm voting to close this question because it is a cross-post from StackOverflow. Cross-posting on StackExchange sites is not allowed. Please choose the site where you expect to receive the best/most answers and post only there. If you'd like to keep the one on Game Development, please delete the one on SO and flag for mod or vote to re-open. \$\endgroup\$
    – Vaillancourt
    Mar 6, 2019 at 16:36

1 Answer 1

2
\$\begingroup\$

Compilation in Unity can be broken down into a few steps:

First is resource compilation. Basically, this is where Unity takes all of your scenes and packages them up. It is during this part that shaders are compiled. However, shaders only need to be compiled when they change. If you make multiple builds in a row, without making any changes to materials that might cause a shader to compile differently, and you don’t change targets to, for example, standalone PC, or clear the library, then the shader compilation is not something you need to worry about.

You can shorten this section of compilation further by simply removing scenes you aren't testing from the build temporarily (uncheck the checkbox in the build settings). These scenes will not be included in the build (and any resources or shaders only used in these scenes will not be compiled) until you re-add them by checking the checkbox again.

The second part of the compilation is compiling code. If you are using il2cpp, this can be quite time consuming. However, you can temporarily switch to target Mono instead of il2cpp for faster compile times (at the expense of slower runtime). Just don't forget to switch back later.

You also have the option to do a script-only build, which skips the first step entirely, assuming you have only made changes to code, and not to any assets, since your last build.

The third part of compilation is simply running the apk compilation. There's not a whole lot I can suggest to make this section faster.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks! But about script-only build. If I only change the positions of the objects inside the scene will it still work properly with this setting? \$\endgroup\$ Feb 25, 2019 at 8:03
  • \$\begingroup\$ If you did that, the change would not be seen in the build until you do a normal build. \$\endgroup\$
    – Ed Marty
    Feb 25, 2019 at 15:14

Not the answer you're looking for? Browse other questions tagged .