Changing address of addressable asset in script

Using Unity version 2020.1.6f1

I am having to convert 150+ assets to be adressable. They are currently loaded from asset bundles. I have set them all to adressable but the auto generated address is not the same as the filename that I load them with using asset bundles and I do not want to go through so many lines of code to hand write the new address for each one (The assets are existing in different folder structures)

What I am trying to do is create a script to execute in editor that will get all the selected assets in the project window and change their address. So far I have been able to get all the selected things from the project window and load the asset but I can’t find if there is a way to change their address programatically.

This is the code I have so far:

foreach(var x in Selection.assetGUIDs)
{
    var asset = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GUIDToAssetPath(x));
    print($"{asset}");
    /* Here I want to do something like Addressables.SetAddress(asset, "...."); */
}

Something like this:

var settings = AddressableAssetSettingsDefaultObject.GetSettings(false);
var asset = settings.FindAssetEntry("<asset guid>");
asset.address = "my new address";
1 Like