I’m trying to setup our build scripts to include addressables, and it’s difficult to find clear documentation or best practice on this. Would like to clarify some things on how things are supposed to be done here.
EditorUserBuildSettings.SwitchActiveBuildTarget(…);
AddressableAssetSettings.BuildPlayerContent();
var options = new BuildPlayerOptions() { scenes = …, locationPathName = “/tmp/Build”, }; // etc
BuildPipeline.BuildPlayer(options);
Is this correct? Does this output any of the built bundles in /tmp/Build?
Or do we need to just do BuildPlayerContent() and copy files over manually, completely unrelated to the player build? If so, where do we copy? How does the player know where to load the files from in that case? Does the player build contain info about the addressables when BuildPlayer() is called? (like the profile used, etc)
Are any of the packaged sharedAssets0.resS actually addressable asset bundles?
Is there documentation somewhere to reference all of this?
It’s quite unclear how the player / addressables talks to each other in builds, and it seems like building and playing from the editor handles a lot of stuff invisibly somehow so it’s not super clear.
Where, and how bundles are copied with the build actually depend on the selected Addressables profile. Your code sequence is about correct I believe. You first need to switch the editor to the required target, build the bundles that need to go with player build, build the player.
Now, depending on the selected Addressables profile, it will copy the existing bundles over to the build. The ‘Default’ profile will do that for you because it saves the built bundles to a path that is copied to the Streaming Assets folder of your project, prior to delivering the final executable.
If you set a different profile with changed values compared to the default profile, it depends on these values whether they get copied along or not. So, as long as you use the Default profile, you should be good with the scenario described above.
Thanks for more details. It is hard to know where all the correct folders are supposed to be, but it looks like one of the confusing issues right now is builds sometimes not copying StreamingAssets out to the destination (which made me think I needed some extra steps). Still trying to diagnose why exactly it isn’t reliably copying out.
I am having the same problem. Unity 2020.2.0b2 does not copy the Default Addressable Asset files over on Build or Build and Run. It has been quite frustrating and will file a bug report based on this answer. About ready to give up on Addressables.