Search Unity

Setting group "include in build" from script

Discussion in 'Addressables' started by TurboHermit, Apr 8, 2020.

  1. TurboHermit

    TurboHermit

    Joined:
    Dec 20, 2011
    Posts:
    40
    Hey there! I'm trying to exclude a specific addressables group from building from an editor script, to speed up our automated build process. We have a pretty large world with ~1600 scenes and an iterative workflow, continuously needing to make builds for both servers and clients. It seems at the moment every time I create a build, it rebuilds all assets in the addressable groups.

    To clarify, this is mostly for local testing, not for production content updates.

    Couple of questions regarding this:
    1. Is there a specific local build setup that will only rebuild dirty assets with iterative changes and not rebuild all groups?
    2. Is there a way to exclude a specific group from a build, via script? I can't seem to find the "Include in Build" option exposed in any of the accessible classes.
    Thanks in advance!
     
  2. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    234
    Re: Include In Build, you can change it in script

    Use FindGroup, then BundledAssetGroupSchema and change the IncludeInBuild flag there
     
  3. bagelbaker

    bagelbaker

    Joined:
    Jun 5, 2017
    Posts:
    67
    I have something like this to include/exclude groups selected in the project window.
    Code (CSharp):
    1.     public static void SetAssetGroupIncludeInBuild(bool includeInBuild)
    2.     {
    3.         foreach (UnityEngine.Object obj in Selection.objects)
    4.         {
    5.             AddressableAssetGroup aag = obj as AddressableAssetGroup;
    6.             if (aag != null)
    7.             {
    8.                 Debug.Log("processing " + aag);
    9.                 BundledAssetGroupSchema bundledAssetGroupSchema = aag.GetSchema<BundledAssetGroupSchema>();
    10.                 if (bundledAssetGroupSchema != null && bundledAssetGroupSchema.IncludeInBuild != includeInBuild)
    11.                 {
    12.                     bundledAssetGroupSchema.IncludeInBuild = includeInBuild;
    13.                     EditorUtility.SetDirty(aag);
    14.                 }
    15.             }
    16.         }
    17.     }
     
  4. TurboHermit

    TurboHermit

    Joined:
    Dec 20, 2011
    Posts:
    40
    Great, that definitely puts me on the right path of excluding things from rebuilding. That being said there's no schema or group settings that will only build dirty content automatically?
     
  5. bagelbaker

    bagelbaker

    Joined:
    Jun 5, 2017
    Posts:
    67
    I think it already does that but since it must check for dependencies and whatnot, it might still be longer than you expect it to be. You can search for it on this forum, someone from Unity has already said it does that automatically.
     
  6. TurboHermit

    TurboHermit

    Joined:
    Dec 20, 2011
    Posts:
    40
    Every time I build (either through the Addressables Groups UI or through BuildPlayerContent) though, it rebuilds everything, that's why I asked if there's a specific set-up to do so.

    I know there is the Content Update workflow, which does that but it also creates a new group (I think) for the updated assets, which becomes unmanageable very quicky with ~1600 scenes and constant iterations.

    And like you said, it's the dependency checking that takes the longest time and even crashes Unity with so many scenes.
    I'm just looking for the most time efficient way of tracking/rebuilding so many assets. I can probably make a custom system to track dirty scenes to rebuild, but the Addressables system seems robust enough to have something like that already?
     
  7. TurboHermit

    TurboHermit

    Joined:
    Dec 20, 2011
    Posts:
    40
    It seems that the Bundle Mode: Pack Seperately rebuilds only dirty assets, so that's the thing I initially looked for.

    Now I've run into a different problem: all shader variants used in a scene are recompiled for every scene which spikes build time as well. I've seen some similar issues on other forums, but no definitive solution yet?
     
  8. TurboHermit

    TurboHermit

    Joined:
    Dec 20, 2011
    Posts:
    40
    Also when excluding a group from the build, it doesn't reference the previous build for that group? Is there an option to reference the previously build bundles for a specific group but build new ones for other groups?