"Simplify Addressable Names", but from code

Hi folks.

When you have the Addressables Groups window open in the editor, you can choose a “Simplify Addressable Names” option by right clicking that shortens the name of all assets in your Addressable Group to the smallest name possible (hides path, extensions, etc). VERY handy.

My question: Is this function accessible from code? I have been able to, in code, create an Addressable Group and load assets into it, but so far I have not found the way to execute the simplify feature on the newly created group.

I’ve tried finding a method to use in the AddressableAssetSettings and AddressableAssetGroup classes, but can’t find anything relevant…

You can find the function call inside Packages/com.unity.addressables/Editor/GUI/AddressableAssetsSettingsGroupTreeView.cs/.
Which is called SimplifyAddresses(object conext) which you can check out :slight_smile:

2 Likes

Great lead, thank you! I didn’t realize I could go dig into Unity code like this. Appreciate your answer.

1 Like

Here, I created an example that should help out based on the info from @Jalict

It should be easily modified to loop through a list of all the assets you want and create short named addressable entries from regular prefabs.

----- Edit - For giggles I added an example of doing so using Odin

3 Likes

var e = settings.CreateOrMoveEntry(guid, group, false, false);
if(!string.IsNullOrEmpty(label))
e.SetLabel(label, true);
if (simplifyNames)
e.SetAddress(e.MainAsset.name);