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.

How to trigger "build player content" when build unity project.

Discussion in 'Addressables' started by Favo-Yang, Jun 4, 2019.

  1. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    459
    I thought "build player content" was automatically triggered when build unity project, as I remembered it was mentioned in an unity conference video. However seems it was not (for both local build and cloud build). I need to manually run build > build player content once, then my local build works.

    Should I write a build processor script for this, or I'm missing something obviously?

    AddressableAssetSettings.CleanPlayerContent(AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilder);
    AddressableAssetSettings.BuildPlayerContent();​

    Addressable 0.8.6
    Unity 2019.1.4f1

    Refs https://forum.unity.com/threads/is-it-compatible-with-cloud-build.653437/

     
    wlwl2, phong-genix and bobbaluba like this.
  2. Ziflin

    Ziflin

    Joined:
    Mar 12, 2013
    Posts:
    118
    I just ran into this as well and would like to know if it is something that should be happening automatically?
     
  3. Kerber996

    Kerber996

    Joined:
    Nov 9, 2016
    Posts:
    23
    It was automatic in the previous versions but in the new ones it was separated as you don't always need to build player content (ex. when you build for content update).
     
  4. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    459
    But the default local group, which packed into streaming assets need always be built among with main build, right?

    At least we can leave an option in the addressable setting file.
     
  5. Kerber996

    Kerber996

    Joined:
    Nov 9, 2016
    Posts:
    23
    Well if you are building the app then yes, you would need to build the default local group(or anything else marked as "static"), but for content updates you don't build the app, and anything that went into the default local group can automagically be put in a new pack by analyzing the rules and applying the fixes.
     
  6. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    459
    The change logs,

    [0.5.2-preview] - 2018-12-14
    IMPORTANT CHANGE TO BUILDING
    We have disabled automatic asset bundle building. That used to happen when you built the player, or entered play mode in "packed mode". This is no longer the case. You must now select "Build->Build Player Content" from the Addressables window, or call AddressableAssetSettings.BuildPlayerContent(). We did this because we determined that automatic building did not scale well at all for large projects.

    Seems the decision related to build performance for bigger project.

    Anyway my 2 cents.
    - Trigger the build button with a popup window, to build with/without addressables.
    - Or you can write a custom build pipeline script to achieve something similar. (IPreprocessBuildWithReport hook didn't work due to "cannot call WriteSerializedFile while a build is in progress" issue).
    - Put "BuildAddressablesProcessor.PreExport" as the PreExport command for cloud build.

    Update: the script can be found at https://gist.github.com/favoyang/cd2cf2ed9df7e2538f3630610c604c51

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.AddressableAssets;
    3. using UnityEditor.AddressableAssets.Settings;
    4. using UnityEngine;
    5. using System.Collections;
    6.  
    7. class BuildAddressablesProcessor
    8. {
    9.     /// <summary>
    10.     /// Run a clean build before export.
    11.     /// </summary>
    12.     static public void PreExport()
    13.     {
    14.         Debug.Log("BuildAddressablesProcessor.PreExport start");
    15.         AddressableAssetSettings.CleanPlayerContent(
    16.             AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilder);
    17.         AddressableAssetSettings.BuildPlayerContent();
    18.         Debug.Log("BuildAddressablesProcessor.PreExport done");
    19.     }
    20.  
    21.     [InitializeOnLoadMethod]
    22.     private static void Initialize()
    23.     {
    24.         BuildPlayerWindow.RegisterBuildPlayerHandler(BuildPlayerHandler);
    25.     }
    26.  
    27.     private static void BuildPlayerHandler(BuildPlayerOptions options)
    28.     {
    29.         if (EditorUtility.DisplayDialog("Build with Addressables",
    30.             "Do you want to build a clean addressables before export?",
    31.             "Build with Addressables", "Skip"))
    32.         {
    33.             PreExport();
    34.         }
    35.         BuildPlayerWindow.DefaultBuildMethods.BuildPlayer(options);
    36.     }
    37.  
    38. }
    39.  
    @Kerber996, see your point. If the addressables is always in the build pipeline, then we lose the tracking for content update (the .bin file in addressables folder). I guess a better approach would be,
    - Always build local group when build the app.
    - Revert the .bin file, until you prepared a content update.
     
    Last edited: Jul 19, 2019
    EDevJogos, wlwl2, Haagndaaz and 5 others like this.
  7. Ziflin

    Ziflin

    Joined:
    Mar 12, 2013
    Posts:
    118
    I would personally expect that if I did a normal app build that any important changes to the addressables were part of that build process. Not doing this just seems to be asking for annoying bugs or tests that aren't accurate. So if it was disabled for performance reasons, then it seems like there needs to be some optimization work done to better track when/what things change.

    As far as doing content updates (I haven't played with it yet), but I would hope there would be a way to do something like: "Mark the current state as v1.0 and save it off". Then when v1.1 is ready have a way to build it using the saved off v1.0 file. Just relying on some previously built state seems very problematic especially for people doing simultaneous builds on multiple platforms as the "final" builds for each platform inevitably have slightly different content changes/fixes.
     
    aubrian and bobbaluba like this.
  8. ALantean

    ALantean

    Joined:
    Nov 13, 2017
    Posts:
    5
    @Favo-Yang, thank you for your script! At the moment I'm struggling with the same issue.

    I have configured my Cloud Build config to execute a Pre-Export method similar to your
    BuildAddressablesProcessor.PreExport
    and I'm actually seeing the logs of this method during builds via Cloud Build. The thing I'm having trouble with is the copying of these cached Addressables (located in the library folder) to the StreamingAssets folder. For some reason my logs do not contain any logs in the form of

    "Copying Addressables data from {0} to {1}. These copies will be deleted at the end of the build."
    (line 33 of
    AddressablesPlayerBuildProcessor
    ).

    When looking at the code of the
    OnPreprocessBuild
    method of
    AddressablesPlayerBuildProcessor
    I'm thinking that the cached Addressable library directory might not exist in my Cloud Build build instance, which contradicts the log messages I'm seeing of my Pre-Export method.

    Maybe you, @Favo-Yang, or someone else can elaborate on their experience with the building process of the Addressables. As far as I can tell
    AddressablesPlayerBuildProcessor
    is called during local builds in the Editor, since it implements the Preprocess-, PostprocessBuild interfaces, but from the logs I'm seeing of my Cloud Builds, I cannot confirm its execution (due to a missing library folder although I previously build it?).

    Note that I'm using the 'Default' profile for everything I've described above.


    Maybe there should be a second check box next to 'Include In Build' to further clarify the behaviour of the group. The second check box triggering a clean build of the Addressables, such that there exist cached assets which can be copied by
    AddressablesPlayerBuildProcessor
    .
     
  9. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    459
    Checked one of the cloud builds. The full logs show that the "copy to StreamingAssets" happens almost right after my PreExport method.

    8930: [Unity] BuildAddressablesProcessor.PreExport start
    ...
    9059: [Unity] BuildAddressablesProcessor.PreExport done
    ...
    9114: [Unity] Copying Addressables data from Library/com.unity.addressables/StreamingAssetsCopy/aa/OSX to /BUILD_PATH/.../Assets/StreamingAssets/aa/OSX. These copies will be deleted at the end of the build.​

    My cloud build configs are almost default, except "Pre-Export Method" set to "BuildAddressablesProcessor.PreExport". I made one mistake that I forget to fill "Pre-Export Method" to all my build targets, caused one target build failed.

    Maybe you can try the “Clean Build" button in the dropdown of "BUILD: ALL TARGETS", see if that is relevant. Or create a empty project with one addressable asset and my processor script, see if you can reproduce the bug.
     
    ALantean likes this.
  10. ALantean

    ALantean

    Joined:
    Nov 13, 2017
    Posts:
    5
    Thank you for your detailed reply!

    After double checking everything and after further investigation it turned that my builds have some issues with the IL2CPP backend during builds of Cloud Build -- I will not go into more detail about this separate issue here.
    In any case, after clearing this up, my builds successfully triggered the
    AddressablesPlayerBuildProcessor.OnPreprocessBuild
    and now copy the cached Addressables into the Streaming Assets folder!

    Thanks again!
     
    Favo-Yang likes this.
  11. Revolter

    Revolter

    Joined:
    Mar 15, 2014
    Posts:
    186
    Thank for that! Didn't work as part of Pre or Post Build Processor
     
  12. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    167
    There should be an option to automaticallt build player content when building, because it is very easy to forget to do the "build player content".

    I agree that there should be better optimization of the asset bundle build process so that if only a few files changed then it doesn't have to do so much.
     
  13. camel82106

    camel82106

    Joined:
    Jul 2, 2013
    Posts:
    304
    Hi,
    I have configured my Cloud Build config to execute yours Pre-Export method.

    But I cannot go through this error while building through cloud?
    Is it even working with latest addressable assets package?

    Thanks
    Peter

    [Unity] -----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/Assembly-CSharp.dll
    64: [Unity] Assets/Scripts/BuildAddressablesProcessor.cs(2,19): error CS0234: The type or namespace name 'AddressableAssets' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
    65: [Unity] Assets/Scripts/BuildAddressablesProcessor.cs(3,19): error CS0234: The type or namespace name 'AddressableAssets' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
    66: [Unity] Assets/Scripts/Catalog/ProblemSceneManager.cs(12,19): error CS0234: The type or namespace name 'AddressableAssets' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
     
  14. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    459
    It's an editor script should be included in Assembly-CSharp-Editor. Have you put it into a folder named Editor?
     
    pandolfini likes this.
  15. camel82106

    camel82106

    Joined:
    Jul 2, 2013
    Posts:
    304
    Oh yeah that makes sense. And sadly not. Your posts on Addressables forum are incredible.
    Thank you very much!
     
    Endahs and Favo-Yang like this.
  16. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    We actually had a lot of reasons to make this change, the largest of which was the optimization. For a very large project, just checking that nothing has changed can take quite a bit of time. To make things worse, it's not uncommon for a user to have a build script that, for example, builds several different variations of Android players that would all reference the same bundles.

    But, I want to hit on one of the other reasons as there's an editor limitation we ran into, and you're going to hit it too. In your code example, you register with BuildPlayerWindow.RegisterBuildPlayerHandler(). This only registers a callback if someone builds via the build window GUI. If they build command line, you can't know about that. For your situation, that may not matter, but for us, a lot of customers use scripts to build, and we really didn't want different behavior if you clicked the build button vs doing command line.

    There are a lot of upsides to Addressables being a package, but one of the downsides is that we end up stuck with some engine/editor limitations we don't like (and can't realistically backport a fix for)
     
  17. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    459
    Well, I know it's not perfect. But it's a pitfall many will fall the first time they build to device.

    I think it's better to have options, like a boolean in the addressable settings file to tell the system whether build player content with a game build. No matter you click the build button, or write your build script, or cloud build. That logic within addressable build processing will keep consistent. You're welcome to turn that off if you don't need it. This will benefit early development, or those mainly use addressable as an asset loader (no download via network).

    Current behaviour is that the system won't build content for you, please write a build script for it. And when it comes to cloud build, you need learn something new with build option UI (also intros inconsistent).

    For those who need the script, I've put it on Github. https://gist.github.com/favoyang/cd2cf2ed9df7e2538f3630610c604c51
     
  18. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    I agree that would be ideal. My point is that the engine doesn't currently have a clean way for us to make that work. We could look at adding it, but at this point it'd be added to Unity 2020.1 at the earliest, and this sort of feature is one we couldn't back port to older versions. That's what I meant by us sometimes being stuck with engine features since we're doing our development in a package.
     
    tigerleapgorge likes this.
  19. Huacanacha

    Huacanacha

    Joined:
    Aug 16, 2013
    Posts:
    58
    I now see a 'Build Addressables" option in Cloud Build. Not sure how long it's been there... Does this negate the need for the PreExport method to initiate Addressables builds?

    If so I might resume my Addressables investigations - I had paused due to build inconsistencies (local vs cloud not behaving the same) and the complexity and fragility of setting up custom build hook methods.
     
    pandolfini likes this.
  20. MartinCoatsink

    MartinCoatsink

    Joined:
    Nov 13, 2019
    Posts:
    7
    Got any updates on this issue, unity_bill?

    ---

    I feel like a decent workaround at this moment is to add a IPreprocessBuildWithReport.OnPrepreprocessBuild hook that will build the asset bundle for you.

    This should work regardless if the build was started from Build Settings Window or batchmode.

    Edit: never mind. Apparently an exception is thrown if I try to do that ...
     
    Last edited: Apr 20, 2020
  21. marwi

    marwi

    Joined:
    Aug 13, 2014
    Posts:
    136
    Id also be interested in knowing what the correct way of automatically building my content is right now. At the moment I have to think about whether or not I need to rebuild my content before building to device - Id rather have an option for the content being automatically rebuild every time rather than realizing I have outdated content after checking on device. This is especially important from an artists standpoint who edits assets and should not be bothered with having to think of multiple steps in order to get a correct build.

    is this something that could potentially be fixed with the scriptable build pipeline (havent yet to try that)
     
  22. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    48
    I have problem with addressables.
    I'm working on local machine. Sure I can make local build addressables. But I'm not making builds on local machine. I make them on Jenkins which download project form GIT. I found that addressables doesn't work on builds made by Jenkins because he doesn't update them. I have on repository addressables_content_state.bin files form local content update but in build made by Jenkins addressables dosn't work.
    Build preprocess doesn't work because it is already in build phase.

    @unity_bill any hints how to solve that?
     
    davidrochin likes this.
  23. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    523
    Just make a script that builds the addressables before building the engine.
    UnityEditor.AddressableAssets.Settings.AddressableAssetSettings.BuildPlayerContent();
     
  24. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    48
    Yes we find out it too. It works for now. But would be great to be able to configure build behaviour within addressables.
     
  25. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    CC @Favo-Yang

    Did anyone find a way to hook this into the Scriptable build pipeline?

    Code (CSharp):
    1. using UnityEditor.AddressableAssets.Settings;
    2. using UnityEditor.Build;
    3. using UnityEditor.Build.Reporting;
    4. using UnityEngine;
    5.  
    6. namespace Editor.Build {
    7.     public class AddressableAssetPreBuildScript : IPreprocessBuildWithReport {
    8.         public int callbackOrder { get; } = 1;
    9.  
    10.         public void OnPreprocessBuild(BuildReport buildReport) {
    11.             Debug.Log("AddressableAssetSettings.CleanPlayerContent...");
    12.             AddressableAssetSettings.CleanPlayerContent();
    13.             Debug.Log("AddressableAssetSettings.CleanPlayerContent!");
    14.  
    15.             Debug.Log("AddressableAssetSettings.BuildPlayerContent...");
    16.             AddressableAssetSettings.BuildPlayerContent();
    17.             Debug.Log("AddressableAssetSettings.BuildPlayerContent!");
    18.         }
    19.     }
    20. }
    21.  
    I'm still getting a
    cannot call WriteSerializedFile while a build is in progress
    on the latest 2019.4.7f1 and
    com.unity.addressables: 1.13.1
    with
    com.unity.scriptablebuildpipeline: 1.10.0
    .

    :(
     
    Ragueel, bobbaluba and francismoy like this.
  26. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    280
    I ... I don't understand. Why is this still necessary??? C'mon Unity ... it's been *years*! 'just make a script' shouldn't be needed in order for this to work as expected.
     
  27. francismoy

    francismoy

    Joined:
    Jul 5, 2017
    Posts:
    40
    Me too on Unity 2019.4.10f1, addressables 1.12.0 and scriptable build pipeline 1.9.0.

    Could you at least explain what this error means and why it's happening?
     
  28. Archimagus

    Archimagus

    Joined:
    Sep 29, 2012
    Posts:
    19
    Unity 2020.2.2f1 here still doesn't just work. I just switched to using addressables and it worked great in the editor, I try a build, no dice. Next to no documentation on how to get it into a build. I finally managed to get a windows build with my assets there by clicking anything that looked related to what the docs were talking about. Still doesn't work in my HTML5 build. Still can't get my batch build script to include the assets in any build. Going to drop addressables I think, they just aren't worth it when they don't work.
     
    aubrian likes this.
  29. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,698
    Hey there @Archimagus - flagging this for the team. Could you tell me which version of Addressables you've been working with?
     
  30. Archimagus

    Archimagus

    Joined:
    Sep 29, 2012
    Posts:
    19
    @TreyK-47 Using Unity 2020.2.2f1 with Addressables 1.16.16.
    I installed the package, checked the box to set a few of my assets as addressable, and used Addressables.LoadAssetAsync<MyAsset>("key"); to load it. It just worked in the editor, no issues. Super happy. Then I went to make a build and my assets were missing. No idea why, made a debug build and the logger told me something about asset key missing, sorry I don't have the actual log any more to remember the exact error. Anyway, I played around in the Addressables->Groups window and tried running a bunch of stuff in the build menu there. It's all super confusing and none of it makes any sense what it's actually doing.
    upload_2021-2-1_14-43-7.png
    Seriously, is it really that complicated when it "just works" in the editor? The documentation is of very little help.
    Anyway, through trying a bunch of those things, and creating a new "packed assets" group I finally got one windows build to work. But not WebGL. Any any time I tried to use my batch build script to build for all the platforms, none of them would get the assets.
    If you need any more info, let me know.
     
    pandolfini likes this.
  31. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    711
    @Archimagus so I imagine that it's working in the Editor fine because you're using the "Use Asset Database" Play Mode Script (which is the default one selected under the Play Mode Script drop down). Make sure you're doing an Addressable content build prior to your player build. Build -> New Build -> Default Build Script by default.

    First off, I do want to say there is an effort to continue adding to/improving the docs. Including restructuring them to be easier for onboarding.

    In regards to Addressables 1.x
    There's no automatically building Addressables player content when doing a player build. But I want to make a few things clear about the reason behind this. It is intentional that we don't build the player content automatically during a player build. We don't do this because it adds to the player build time in ways that are easily avoided by us not making the assumption you want your content built on every player build. Even using the build cache this would still add unnecessary time. You might ask "well just don't do a content build if nothing has changed" but the way we'd figure out if something has changed is by building dependency trees, hashing assets + dependencies, etc. which again, adds time to the build that could be avoided. Also, we don't want to make the assumption you want your content built on a player build. What if you've done a content update build (not a regular build) and are deploying a new player build as well? We shouldn't stop all over your current AssetBundle setup just because you built a player.

    This is why, for things like this, we recommend "make a script" if that's the behavior you're looking for. We try and help provide APIs and tools so you can have these custom behaviors if you want.

    Now, onto another part of this thread, the "cannot call WriteSerializedFile while a build is in progress" issue. Unfortunately calling these file writes in the Addressables build player content as part of a player build callback (ie using the IPreprocessBuildWithReport) is an engine side limitation that we don't have control over. I'd recommend, if you're looking for a way to do the Addressables content build and a player build in one go to have something like
    Code (CSharp):
    1. [MenuItem("Build/Full Addressable and Player Build")]
    2.     void FullBuild()
    3.     {
    4.         AddressableAssetSettings.BuildPlayerContent();
    5.  
    6.         BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, "MyBuildPath/build.exe",
    7.             EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);
    8.     }
    In order to separate those two processes and keep them from interfering with one another.

    In regards to Addressables 2.x
    This is something that is in the discussions for what we would want for an Addressabes v2. Likely in the future auto building content as part of a player build will be a thing for v2 and will likely be on by default so as to cut down on the confusion for onboarding and new projects. Then, as the project matures, it may be desired not to have content builds perform automatically anymore for any or all of the reasons we don't do auto content builds now. So we'll provide this as an option that you can turn on/off.

    I hope this sheds some light on the situation and helps clear a few things up. Thanks, all.
     
    aubrian, wlwl2, konsnos and 1 other person like this.
  32. rg_software

    rg_software

    Joined:
    Apr 29, 2017
    Posts:
    7
    @davidla_unity, you suggest that BuildPlayerContent() can be followed by BuildPlayer() to produce a complete build. I tried this approach on Unity 2018.4 (command-line batch mode), but ended up with "Addressable Asset Settings does not exist" error. There is a closed issue on Unity bugtracker ("won't fix") with the following comment: "user's build script is attempting to build addressables while the editor is compiling code. This cannot be done."

    So, how is it supposed to work? My build script starts with the AddressableAssetSettings.BuildPlayerContent() call, and still I have isCompiling == true, so it fails immediately. Furthermore, isCompiling is true till the very end of a method I call (even if it is empty), so there is no way I can wait till it becomes false.
     
    Last edited: Feb 27, 2021
  33. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    711
    @rg_software yeah, that's a good point. We're actually looking into removing that restriction from our code but are trying to make sure it's safe to do. For users running into this problem you can try:
    1. Editing the package to remove the check in AddressableAssetSettingsDefaultObject.Settings getter to not check for isUpdating and isCompiling (you'll have to copy the package from the Library/PackageCache folder into the Packages directory) and see if that works for you.
    2. Or, before you call Addressables.BuildPlayerContent() you can set the AddressableAssetSettingsDefaultObject.Settings (this is assuming you aren't using a custom settings for anything) and actually set that property yourself using Resources.Load<AddressableAssetSettings>("pathtomysettings"). Unless there's another domain reload this should set the internal reference to the settings object and then you won't have to care if you're compiling or not.
    Hope these help. Let me know if there's any more trouble.
     
  34. Driiade

    Driiade

    Joined:
    Nov 21, 2017
    Posts:
    80
    Whatever we use, it's just not working as expected.

    Code (CSharp):
    1.         UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
    2.  
    3.         if (EditorUtility.DisplayDialog("Build with Addressables",
    4.             "Do you want to build a clean addressables before export?",
    5.             "Build with Addressables", "Skip"))
    6.         {
    7.             PreExport();
    8.         }
    9.  
    10.         if (EditorUtility.DisplayDialog("Build with Optimization",
    11.          "Do you want to bake a clean optimization before export?",
    12.           "Build with Optimization", "Skip"))
    13.         {
    14.             BakeOptimizationsOnAllPackages();
    15.         }
    16.  
    17.         BuildPlayerWindow.DefaultBuildMethods.BuildPlayer(options);
    with

    Code (CSharp):
    1.     /// <summary>
    2.     /// Run a clean build before export.
    3.     /// </summary>
    4.     static public void PreExport()
    5.     {
    6.         Debug.Log("BuildAddressablesProcessor.PreExport start");
    7.         AddressableAssetSettings.CleanPlayerContent();
    8.         AddressableAssetSettings.BuildPlayerContent();
    9.         Debug.Log("BuildAddressablesProcessor.PreExport done");
    10.     }
    And it doesn't work.

    We lost ton of hour checking why it's not working between developers and QA.
    And the fact is, now we have to remember to click on multiple windows to "Build->New Build->Default Build Script"

    And yes it's a salty post, but just we want to build a game first, before having something optimized.

    And on this post, no one can share a real solution for baking these addressables from script, right before calling
    BuildPlayerWindow.DefaultBuildMethods.BuildPlayer(options);
     
  35. Driiade

    Driiade

    Joined:
    Nov 21, 2017
    Posts:
    80
    Sometime you have to Clean because addressable are not included. After cleaning it work again.
    We don't understand.
     
  36. andymilsom

    andymilsom

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    205
    We have changed it so that Setting can be returned when isCompiling, but I would still strongly advise not doing so if possible. There is a lot that can go wrong that is hard to debug the cause of, if you change the code during execution (scripting defines/platform switch) and "isCompiling", then you are executing old code, and not the new code that you may be expecting.

    How come are you calling, UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();?
    There should be no reason here as to why you need to do that, have you found issues if you do not?

    "Sometime you have to Clean because addressable are not included. After cleaning it work again.
    We don't understand."

    I also do not understand, I have never seen an issue where the addressables are not included if you do not clean. If you can demonstrate this in a bug report, we will be able to look into it and find any issues.
     
    pandolfini and wlwl2 like this.
  37. Driiade

    Driiade

    Joined:
    Nov 21, 2017
    Posts:
    80
    UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();

    I change define symbol for QA and different build.

    Sincerely we now just click on button. I just put a message to remind them to do so. It's just very anoying because now build take 30 minutes to be tested because the game is Huge, and when you have "error" like that, you just want to throw the computer.

    It's just for our mental sanity, if you can do something, do it :eek:

    The best will be that building addressable on a computer, can be sent on git. But it's not the case.
     
    Jorhoto and ProtoTerminator like this.
  38. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    1,226
    Hi @davidla_unity. Can you tell me more about Addressables v2? Does v2 will be designed exclusively for DOTS?
     
    aromana likes this.
  39. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    280
    Using Unity 2020.3.18, Addressables 1.19.4 - I have 'build addressables content on player build' selected in addressable asset settings ... it doesn't do anything :(
     
  40. andymilsom

    andymilsom

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    205
    Ahh, yes that requires engine features from 2021.2. I will get that disabled when not on the right Unity version.
     
    Aurigan likes this.
  41. bunp

    bunp

    Joined:
    Feb 21, 2019
    Posts:
    47
    upload_2022-1-15_11-9-15.png

    Im having this problem as well but I am on the latest unity so it might work for me. Where is that option you refer to? I feel blind because I can't find it.
     
  42. Revolter

    Revolter

    Joined:
    Mar 15, 2014
    Posts:
    186
    Create AddressableAssetsBuildProcessor.cs in an Editor folder

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.AddressableAssets;
    3. using UnityEditor.AddressableAssets.Settings;
    4. using UnityEngine;
    5.  
    6. namespace BuildProcessors
    7. {
    8.     public class AddressableAssetsBuildProcessor
    9.     {
    10.         [InitializeOnLoadMethod]
    11.         private static void Initialize()
    12.         {
    13.             BuildPlayerWindow.RegisterBuildPlayerHandler(BuildPlayerHandler);
    14.         }
    15.  
    16.         private static void BuildPlayerHandler(BuildPlayerOptions options)
    17.         {
    18.             if(AddressableAssetSettingsDefaultObject.Settings != null && EditorUtility.DisplayDialog("Build Addressables", "Build Addressables?", "Build", "Skip"))
    19.                 PreExport();
    20.             BuildPlayerWindow.DefaultBuildMethods.BuildPlayer(options);
    21.         }
    22.  
    23.         private static void  PreExport()
    24.         {
    25.             Debug.Log("BuildAddressablesProcessor.PreExport start");
    26.             AddressableAssetSettings.CleanPlayerContent(
    27.                 AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilder);
    28.             AddressableAssetSettings.BuildPlayerContent();
    29.             Debug.Log("BuildAddressablesProcessor.PreExport done");
    30.         }
    31.     }
    32. }
     
    Eclectus and Yamity like this.
  43. Eclectus

    Eclectus

    Joined:
    Oct 29, 2012
    Posts:
    17
    This solution worked well for me!
    Thankyou
     
  44. xuyennguyen

    xuyennguyen

    Joined:
    Mar 3, 2014
    Posts:
    2
    Hi,
    Do we have a way to build the local group only when building app?
     
    Last edited: Jun 26, 2022
unityunity