Set Build & Load Paths in script during custom build

Hi, Im trying to modify the Build and Load paths of every addressable group, in the editor that’s easy, but what’s the way to do it in a script during a custom build? I want to change it to Remote during build basically.
9864498--1421334--upload_2024-5-30_15-42-27.png

1 Like

Just curious, what’s your use case for wanting to change that as part of a build?

Generally, we’d suggest creating multiple profiles and swapping the active profile instead of trying to change the Build/Load path as part of a custom build script.

The problem I’m having with changing profiles is that, that alone does not change the Build & Load paths type, so for example, when using the editor I need to have it in Local, or when doing casual buildings I also just leave it in Local, but when building for testing I need it in Remote so it will download the assets from a remote server. I already change the profile by code, but since the paths type is still in Local I can’t really fully automate the process.

I have 3 profiles, dev, test and production, all 3 have Local and Remote paths, if I’m working using the Local path in dev, and the I change to test, the path type is still Local, and that is the problem.
What you suggest is that I can create 3 extra profiles, so dev local, test local, production local and dev remote, test remote and production remote, and in every profile have only one custom Local or Remote build and load path, is that correct or am I getting it wrong?, I think that might solve the problem, but I didn’t try it yet and I’m not even sure if it can be done that way.

Reviving this thread to illustrate a way to achieve what @votagus was looking for. Using the following method you can force the Addressable Settings asset to update build paths after changing the selected profile.

AddressableAssetSettings s = AddressableAssetSettingsDefaultObject.GetSettings(false);

if (remoteContent)
{
    //Retrieve remote profile and set it to active
    var remoteProfile = s.profileSettings.GetProfileId(RemoteContentProfile);
    s.activeProfileId = remoteProfile;

    //Force the settings asset retrieve the current profile settings
    s.RemoteCatalogBuildPath.SetVariableByName(s, "Remote.BuildPath");
    s.RemoteCatalogLoadPath.SetVariableByName(s, "Remote.LoadPath");
}
else
{
    var localProfile = s.profileSettings.GetProfileId(LocalContentProfile);
    s.activeProfileId = localProfile;

    //Force the settings asset retrieve the current profile settings
    s.RemoteCatalogBuildPath.SetVariableByName(s, "Local.BuildPath");
    s.RemoteCatalogLoadPath.SetVariableByName(s, "Local.LoadPath");
}

I’m not sure whether this is ‘best practice’ around Addressables or not, but I effectively had the same issue @votagus describes whilst attempting to automate some behaviour during builds.

As far as I can tell, the only other way to achieve this is to create profiles where both the Local and Remote build paths point to the same locations; otherwise you will always need to manually specify that the build paths should be Remote via the settings inspector..

hi david
if i configure the remote loadpath which is generated from my oss or s3 bucket, is there safe? I mean does anyone could grab this path by some proxy agent?
thank you

It depends what you mean by safe. Anyone using your game would easily see the Load paths, as the game needs to connect to that to download the asset bundles.