I’ve been looking at documentation for hours and can’t find relevant method that can access existing addressable asset setting object. I’m trying to access it during custom build script so that I can build from specific profile. Anyone know how to access existing addressable asset setting in code? (preferably through addressable system)
Hey @VaygrEmpire I think what will help you out is AddressableAssetSettingsDefaultObject.Settings
Hope that helps! Let me know if you still have trouble.
Thanks, @davidla_unity ! But I have another question regarding addressable asset system. I’m trying to build it in custom build script and when I called AddressableAssetSettings.BuildPlayerContent();, Editor gave me null reference in path. So I’m trying to access existing addressable asset setting object’s build path.
How do I access paths under profile setting and pass it through BuildPlayerContent()?
EDIT*****
Actually I figured out how to get path. Now I just need to find a way to pass it to somewhere so that BuildPlayerContent() gets working…
So the Addressables Build Path is not something we current allow modifications to. Are you saying BuildPlayerContent() is failing with an error? BuildPlayerContent() should build everything to Library/com.unity.addressables/StreamingAssetsCopy/aa/" + YourPlatformName
@davidla_unity yeah when I just put following lines of codes I get path error…
or so I thought. Fixed it but now I’m more confused. So on default setting I have 2 profiles: Default and Remote. Each of them have different paths designated. When I build, how does it know which profile I want it to build?
var profileSetting = UnityEditor.AddressableAssets.AddressableAssetSettingsDefaultObject.Settings.profileSettings;
var profileID = profileSetting.GetProfileId("Remote");
var names = profileSetting.GetVariableNames();
for (int i = 0; i < names.Count; i++)
{
if (profileID == profileSetting.GetProfileId("Remote"))
{
AddressableAssetSettings.BuildPlayerContent();
}
}
I tried above but it builds for both Default and Remote profiles.

So it should pull the build paths and load paths from the active profile set here.
Apologies if my previous comment was confusing. I think I misunderstood and thought you were trying to set the BuildPath property in a script.
that was where I was going actually until your replied so nope you were correct on the issue.
Thanks! Is it possible to build without setting anything in that Addressable Groups window but setting things straightly in code only? trying to create automated addresable asset build here.
So, I think what you’ll have to do is get the Addressable group, get the BundledAssetGroupSchema and then set the build path of that group before calling build content. Something like this should get what you’re going for
var group = AddressableAssetSettingsDefaultObject.Settings.FindGroup("groupName");
group.GetSchema<BundledAssetGroupSchema>().BuildPath.SetVariableByName(AddressableAssetSettingsDefaultObject.Settings, "MyBuildPath");
Hope that helps! Let me know if you still have trouble.
Hmm, that’s one way to build it, but I got curious with another way to build - through profile. I was able to changing profile setting in script, but calling BuildPlayerContent() ended up building stuff into several folders outside Assets directory. I assume when BuildPlayerContent() is called, it builds to Local or Remote path based on Build Remote Catalog bool state? What’s the best approach to call Build once you change profile setting to something else, then build to that profile’s build path?
Or am I back to un-modifiable build path problem again?
Ah, yes, so in that case you should be able to do AddressableAssetSettingsDefaultObject.Settings.activeProfileId = AddressableAssetSettingsDefaultObject.Settings.profileSettings.GetProfileId(n); where “n” is the string name of your profile you’re trying to change it to.
It may also be necessary to set the settings object as dirty with EditorUtility.SetDirty(AddressableAssetSettingsDefaultObject.Settings); but I haven’t tested it and this may not be required. Just something to try if need be.
var addressableAssetSettings = AddressableAssetSettingsDefaultObject.Settings;
var desiredProfileSelection = "Remote";
if (desiredProfileSelection == addressableAssetSettings.activeProfileId)
{
Debug.Log("current profileID is " + desiredProfileSelection);
}
else
{
if (addressableAssetSettings.profileSettings.GetAllProfileNames().Contains(desiredProfileSelection))
{
if (addressableAssetSettings.activeProfileId != desiredProfileSelection)
{
addressableAssetSettings.activeProfileId = desiredProfileSelection;
Debug.Log("changing profileID to " + addressableAssetSettings.activeProfileId);
EditorUtility.SetDirty(AddressableAssetSettingsDefaultObject.Settings);
AddressableAssetSettings.BuildPlayerContent();
}
}
}
@davidla_unity I really appreciate all your help on this matter and I’m really sorry to keep bothering you…
So what I’m trying to do is test custom build script using Addressable System. When I build with above code, what I expect is to be built at red circled build path. Instead, it builds outside Assets folder, not to mention it’s not building to correct path - red circled one. I think it’s building to Profile: Default build path rather than changed profile’s build path.
What am I doing wrong? And how can I fix this?
Hey no problem at all. I’m sorry I was missing something in what I said you needed to do. If you change your code from
addressableAssetSettings.activeProfileId = desiredProfileSelection;
Debug.Log("changing profileID to " + addressableAssetSettings.activeProfileId);
EditorUtility.SetDirty(AddressableAssetSettingsDefaultObject.Settings);
AddressableAssetSettings.BuildPlayerContent();
to
var id = addressableAssetSettings.profileSettings.GetProfileId(desiredProfileSelection);
addressableAssetSettings.activeProfileId = id;
Debug.Log("changing profileID to " + addressableAssetSettings.activeProfileId);
AddressableAssetSettings.BuildPlayerContent();
it should work. That code worked for me at least. The thing I forgot was that you need to convert the group name to the groups internal id (addressableAssetSettings.profileSettings.GetProfileId(desiredProfileSelection))
Let me know if you still have trouble!
Thanks! It finally worked! Built to correct location!
@davidla_unity Question just popped up regarding changing build path. So it is not possible to change build path automatically with addressable? Say, if there’s difference between versions it’ll create new folder and build it there. Is such thing possible?
So, I can check and see if there’s a better solution that has been implemented in the past but off the top of my head I would say you would need to do what we discussed before and change the build path on the group to include the version number.
I will say I seem to remember some users having trouble with updating a build if they were building to new directories every time but I can’t remember exactly what the issue was. Just something to keep in mind.
I know we can parameterize parts of the build and load paths but I’ll have to look into if it’s easily possible to add custom variables to use with this.
@davidla_unity Is it also possible to change the name of the build? Currently when you build it is named as “catalog” + version numbers. Is it possible to customize “catalog” part?
Moreover, is there documentation page for “Bundle Asset Provider Types”?
Thanks for help!
No, it isn’t possible currently to change the “catalog” part.
Doing a quick scan of our documentation it doesn’t appear that we do. We’re working on getting better docs updated/added. If you click the Documentation link in the Addressables section in Package Manager it should take you to what documentation we currently have. Though I’ve heard that Package Manager doesn’t always take you to the most updated docs sadly.
No problem, happy to help.
At least in version 1.2.2 I am able to change the catalog name. You check build remote catalog and then put something in player version override and it appends that to your catalog… so you have like catalog_MyPlayerVersionOverrideString.json
Both of those settings can also be configured via editor scripts as well.
thanks but I meant specifically that “catalog” part
@davidla_unity We’re developing using several different environments such as Dev, Test, Live and use a standard CI practice of build once and promote those builds up the environment heirarchy as they pass various stages of testing. The problem is that each environment has a different URL, but the RemoteLoadPath seems to get built into the addressables build as a single URL.
Is there a way to modify that at runtime?
RemoteLoadPath: www.dev.somesite.com/[BuildTarget]
runtime change this to be: www.live.somesite.com/[BuildTarget]
Or is there some sort of variable lookup we could put into a config file using a custom variable?
RemoteLoadPath: www.[Environment].somesite.com/[BuildTarget]
config set Environment variable to be: “live” so it uses: www.live.somesite.com/[BuildTarget]


