Hi all,
I want to make a custom editor window to rename some asset base on result return from server.
Is there anyway to mark an asset as addressable and rename it by using c# script?
I have been looking for document from unity but didn’t find any solution yet.
Thank you very much!
I think what you’re looking for is a combination of
AddressableAssetSettingsDefaultObject.Settings.CreateOrMoveEntry(...)
and the address property of an AssetEntry. You could try
AddressableAssetSettingsDefaultObject.Settings.FindAssetEntry("AssetGUID").address
If you don’t know the guid of your asset but you know the path you can utilize AssetDatabase.AssetPathToGUID(...)
Hope that helps!
4 Likes
Thank you very much! I’ve solved my problem.
Here is the code for anyone want to do this:
string path = AssetDatabase.GetAssetPath(source);
string guiID = AssetDatabase.AssetPathToGUID(path);
AddressableAssetSettingsDefaultObject.Settings.CreateOrMoveEntry
(guiID, AddressableAssetSettingsDefaultObject.Settings.DefaultGroup, false, true);
AddressableAssetSettingsDefaultObject.Settings.FindAssetEntry(guiID).address = "MyAddress";
3 Likes