Migration path

I’m migrating a project that previously used direct references to using Addressables. To help migrate things, I build some quick tools to walk through the data-set and check if there’s an equivalently named Addressable. This of course assumes that the addressable already exists, and that the name is the same.

[Serializable]
public class AssetReferenceSprite : AssetReferenceT<Sprite>
{
    public AssetReferenceSprite(string guid) : base(guid) { }
    public bool isSet { get { return RuntimeKeyIsValid(); } }
}

public class Bar
{
[SerializeField] Sprite    foo; // legacy
[SerializeField] AssetReferenceSprite  fooRef;  // copy legacy to here
}

I’ve dug out the AddressableAssetEntry from the database ; that part is simple enough.

So I have the GUID. How do I go from that, to an AssetReferenceT ?

And I guess I’ve gotten so used to beating my head off the Addressable system that the simple solution didn’t occur to me :slight_smile:

var entries =AddressableHelper.FindEntry<Texture2D>(node.foo);
if (entries != null && entries.Count > 0)
{
   node.fooRef = new AssetReferenceTexture2D(entries[0].guid);
}