Locating asset path at runtime

Hello!

For my game I have a map editor at run time which requires loading of prefabs. It would be very handy if when in unity editor i could access the path of a labelled addressable, for example something like:

    public GameObject GetPrefab()
    {
#if UNITY_EDITOR

        if (!Application.isPlaying)
        {
            GameObject prfb = PrefabUtility.CreatePrefab(Addressables.AssetPath(assetLabel));
            return prfb;
        }
#endif
        string path = "Assets/Bundles/";
        GameObject g = AssetBundleManager.loadGameObjectAsset(shortName);
        return g;
    }

Is this already possible in some sort of way? The Addressables Groups tab maintains a path to the asset so it feels like in some sort of way it should be do-able, even if its in a hacky way. If its not currently possible, could it be a feature request?

There’s a number of methods to get addressable asset entries in the editor, through the AddressablesAssetSettings: Class AddressableAssetSettings | Addressables | 1.21.21

This is generally accessed by AddressableSettingsDefaultObject.settings.

Edit: Mind you I don’t think this requires the addressable API. You can probably do this through AssetDatabase.

1 Like

Thank you, I’ll give this a go