Hi all,
I use UCB and I am start to use addressables on my project.
In my case I have UCB pipelines to build the game regarding the environment that we want (Dev/Staging/Production).
Also reflecting that I have Addressables profiles reflecting those environments.
My problem is:
I am trying to change those profiles with UCB Environment Variables, so each build will point to the respective Addressables profile.
I was trying to use a IPreprocessBuildWithReport in order to change it on UCB.
However it seems that the AddressableAssetSettingsDefaultObject.Settings is not being changed.
Here is the code:
public void OnPreprocessBuild(BuildReport report)
{
var profileSettings = AddressableAssetSettingsDefaultObject.Settings.profileSettings;
string activeProfileName = "Dev";
#if UNITY_CLOUD_BUILD
Debug.Log("[AddressablesProfileSelector] Unity Cloud Build");
var profile = Environment.GetEnvironmentVariable("ADDRESSABLES_PROFILE");
activeProfileName = profile != null && !profile.Equals(string.Empty) ? profile : "Dev";
#elif UNITY_EDITOR
activeProfileName = "Dev";
Debug.Log("[AddressablesProfileSelector] Unity Editor");
#endif
var id = profileSettings.GetProfileId(activeProfileName);
Debug.Log(string.Format("[AddressablesProfileSelector] Profile: {0}", activeProfileName));
AddressableAssetSettingsDefaultObject.Settings.activeProfileId = id;
EditorUtility.SetDirty(AddressableAssetSettingsDefaultObject.Settings);
}
I don’t know if my flow is wrong, or if I am missing some step on that.
Please, any help will be great!