Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug "Build Addressables" option incompatible with Unity 2021.2

Discussion in 'Unity Build Automation' started by aromana, Nov 29, 2021.

  1. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    137
    tl;dr Unity Cloud Build with "Build Addressables" option is not aware of the new "Build Addressables On Player Build" option introduced in Unity 2021.2, causing addressables to be built twice, resulting in a non-functional builds due to remote catalog mismatch.

    Unity 2021.2 introduced a new option, "Build Addressables On Player Build", to automatically build addressable assets whenever the player is built. This is useful when developing locally, as it saves several clicks and having to remember to do so. Thus, it's good practice to turn this on, and to commit to to source code so the whole team can benefit.

    However, when Unity Cloud Build is configured with "Build Addressables", and the project also has "Build Addressables On Player Build" set to anything other than "Do not build", addressables will get built twice: first when Unity Cloud Build triggers a build of Addressable Assets content because of the "Build Addressables" option, and then again because addressables triggers a build due to the "Build Addressables On Player Build" preference.

    This causes serious issues with the build process: namely, the remote catalog built into the player will not match the one uploaded to Cloud Content Delivery. This essentially silently breaks CCD integration for non update-only builds.

    Making matters worse, while one option for "Build Addressables On Player Build" is to set it to whatever the editor's default is ("Use global settings"), this option defaults to TRUE. See source from from
    AddressablesPlayerBuildProcessor.cs:137
    :

    Code (CSharp):
    1. if (!EditorPrefs.GetBool(AddressablesPreferences.kBuildAddressablesWithPlayerBuildKey, true)) return false;
    2.  

    There are several possibly solutions to fix this, and I'll leave it to the Unity team to decide how to handle this. For example, you could add compile-time guards like
    #if UNITY_CLOUD_BUILD
    inside
    AddressablesPlayerBuildProcessor
    to always treat "Build Addressables On Player Build" as
    false
    , or you could add prebuild hooks to UCB runner to disable "Build Addressables On Player Build" if the UCB config is set to build addressables, etc.
     
    Gigacee likes this.
  2. Gigacee

    Gigacee

    Joined:
    Mar 4, 2015
    Posts:
    52
    Hi, I upgrading my project from Unity 2020 LTS to Unity 2021 LTS and faced the same problem.
    I guess that many people seem to have the same condition ("Build Addressables on Player Build" option is "Use global Settings"), so I consider it a very serious problem.
     
  3. michael_unity145

    michael_unity145

    Joined:
    Mar 8, 2022
    Posts:
    21
    Any updates on this? Having the same issue. It's really confusing that addressables get built twice, providing the wrong catalog
     
  4. Danny327

    Danny327

    Unity Technologies

    Joined:
    Jan 4, 2021
    Posts:
    78
    Whoever is experiencing this issue, please submit a support ticket to the Cloud Build group. One of our support agents will be assigned to this issue and start investigating. Thanks!