I’m blind or this is over-complicated…
Edit
Tried this but it doesn’t work:
I’m blind or this is over-complicated…
Edit
Tried this but it doesn’t work:
Found it, it’s impossible to change the “” profile/option in Build Path but every other can be changed with:
groupAsset.Settings.profileSettings.SetValue( groupAsset.Settings.activeProfileId, "LocalBuildPath", yourPathHere );
My Feedback: there should be simple groupAsset.Settings.BuildPath that could be set.
BundledAssetGroupSchema bundledAssetGroupSchema =
addressableAssetGroup.GetSchema<BundledAssetGroupSchema>();
bundledAssetGroupSchema.Compression = BundledAssetGroupSchema.BundleCompressionMode.LZMA;
bundledAssetGroupSchema.BuildPath.SetVariableByName(aaSettings,
aaSettings.profileSettings.GetValueById("Default", "RemoteBuildPath"));
bundledAssetGroupSchema.LoadPath.SetVariableByName(aaSettings,
aaSettings.profileSettings.GetValueById("Default", "RemoteLoadPath"));
I was able to change Build Path and Load Path in this way in Addressables 1.20.3.
It’s not correct, you set value by name, but in name parameter set conctete value.
Correct way it’s:
bundledAssetGroupSchema.BuildPath.SetVariableByName(aaSettings, "RemoteBuildPath");
bundledAssetGroupSchema.LoadPath.SetVariableByName(aaSettings, "RemoteLoadPath");
For set concrete value need use #Kamyker code:
I am currently facing a similar problem where I need to change the value of the asset provider, but I have been unable to locate a single place where it can be modified programmatically. There is provisioning to access for changing the compression value as well as build mode as mentioned in the above threads but there is no way to set the Asset provider value.
var settings = AddressableAssetSettingsDefaultObject.Settings.DefaultGroup;
BundledAssetGroupSchema assetGroupSchema = settings.GetSchema<BundledAssetGroupSchema>();
assetGroupSchema.Compression = BundledAssetGroupSchema.BundleCompressionMode.LZ4;
@Kamyker these “Custom” fields use a legacy API. “Custom” values are stored as the Id of the variable and there isn’t a way to modify them using public APIs.
What I would suggest is to define a new Path Pair on your Profile. Profiles are setup to have “Local” and “Remote” path pairs by default, but you can add as many as you want.
To add path pairs I go in and click on Create->Build and Load Path Variables in the Addressables Profiles window:
Then I create a new combo called MyTestVars
Now I can use code like yours to set my group to my build and load path to this path pair:
var settings = AddressableAssetSettingsDefaultObject.Settings;
var group = settings.FindGroup("groupName");
var idInfo = settings.profileSettings.GetProfileDataByName("MyTestVars.BuildPath");
group.GetSchema<BundledAssetGroupSchema>().BuildPath.SetVariableById(settings, idInfo.Id);
idInfo = settings.profileSettings.GetProfileDataByName("MyTestVars.LoadPath");
group.GetSchema<BundledAssetGroupSchema>().LoadPath.SetVariableById(settings, idInfo.Id);
private static PropertyInfo _bundleProviderProperty;
_bundleProviderProperty = typeof(BundledAssetGroupSchema).GetProperty(nameof(BundledAssetGroupSchema.AssetBundleProviderType),
BindingFlags.Instance | BindingFlags.Public);
public static void SetBundleProvider<T>(BundledAssetGroupSchema schema)
{
_bundleProviderProperty.SetValue(schema, new SerializedType() { Value = typeof(T) });
}
@fawadasghar82 @Flexford reflection is indeed the only way to set it currently. We plan to make the BundleProvider public in a future release.
It works but with the “Local.BuildPath” or “Remote.BuildPath” for the recent version of Addressables
@timtunity3d Sadly we can’t use the profile pairs, since the schemas use guids to identify those. Our Addressables are in packages, which means those guids will break when the package is installed in another project. Cloning them into the project via import groups also isn’t really viable, since that adds a manual installation/update step for each of our internal asset packages (which frequently get updated in 20+ projects). For this reason we currently use custom build/load paths, but these randomly break, since addressables seems to check for the profile build/load path regardless of set custom paths at several points (one example is the addressableAssetProfileSettings.GetValueById, which is used in ErrorCheckBundleSettings in BuildScriptPackedMode. It gets the custom path as a parameter, but as long as it finds the active profile it will use that for dermining the path - even if that finds nothing and return null.
So, before I go and start a fork for the package and maintain that, is there a better way?