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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question InvalidKeyException when disable Include in build

Discussion in 'Addressables' started by JoanBrugaya, Jan 22, 2023.

  1. JoanBrugaya

    JoanBrugaya

    Joined:
    Jan 6, 2021
    Posts:
    2
    Hi there,

    I'm building an app that will include many scenes and in order to not have an app that is > 10Go, we're implementing addressable system. The thing is that when we disable the "Include in build" checkbox to avoid having selected assets in build, when we try to LoadAssetAsync, giving the AssetReference we get a InvalidKeyException.

    All works when this checkbox is enabled, addressablesManager is downloading from our remote server. But doesn't work if we disable the checkbox.

    Anyone has an idea ? Maybe we didn't understand correctly the purpose of this checkbox ? If so, how can we exclude these assets from the build ?

    Thank you very much !
     
  2. LuGus-Jan

    LuGus-Jan

    Joined:
    Oct 3, 2016
    Posts:
    169
    I think you indeed might misunderstand the 'Include in build' checkbox, because this checkbox only defines whether the group should be included in the content build.

    Essentially, when using Addressables in your project, there are 2 builds that you must make: a content build (everything included in Addressables) and a player build (your app). First, the content build has to be made, and afterwards the player build. When the player build is being made, it will include a content catalog file of the content build. This file effectively decides what content is available in your game, locally and remotely.

    The 'Include in build' checkbox on Addressable groups is to say whether they should be included in your content build. It doesn't have any effect on the player build. If you untick the box of an addressable group, it will create a new content catalog file that excludes the addresses of the content that reside in that group. So this checkbox should not be changed between builds when using remote content.

    When you want to make a build that doesn't produce a new content catalog file, instead, check the 'Build Addressables on Player Build' option on your Addressables Asset Settings object. You can disable a content build on player build, which leaves the content as is and only produces an app build with code fixes etc. that doesn't affect the content. Perhaps this is what you were looking for?
     
    JoanBrugaya likes this.
  3. JoanBrugaya

    JoanBrugaya

    Joined:
    Jan 6, 2021
    Posts:
    2
    Thank you @LuGus-Jan for your very detailed response ! :)

    Ok, I understand that I should not disable that checkbox if I need the addressables contained in this group.

    So my problem is somewhere else :) It seems that my remote addressables are included in my build because I can see my player build size increased as I add new content in my remote addressables. I've seen that it could be a dependencie issue that force my assets to be included in the player's build.