How to edit AssetBundleProviderType by code

I’m writing a custom editor to alternate an addressable group between local and remote.

I can change the BuildPath and the remote Path like this:

BundledAssetGroupSchema schema;

schema.BuildPath.SetVariableByName(settings, "RemoteBuildPath");
schema.LoadPath.SetVariableByName(settings, "RemoteLoadPath");

but I also need to change the AssetBundleProvider to a custom Provider.

I was trying to do it like this:

SerializedType schemaBundledAssetProviderType = schema.BundledAssetProviderType;
schemaBundledAssetProviderType.Value = typeof(MyCustomProvider);

But since BundledAssetProviderType is a SerializedType wich is a struct, when i change the Value property it only modifies a copy stored in the schemaBundledAssetProviderType variable.

Is there a way modify the reference inside the schema?

Use reflection to get around the private-ness of the property:

var p=schema.GetType().GetProperty("AssetBundleProviderType");
var t=new SerializedType();
t.Value=typeof(MyCustomProvider);
p.SetValue(schema,t);

Fugly but it works.