Managed asset keys don't work with content packs
Pathoschild opened this issue ยท 1 comments
When a managed asset key is handled by a content pack, SMAPI fails to load the file because it only checks mods.
See:
This seems to be an issue with the way that mod loads the content. It's logging this debug line:
[MapLoader] calling contentHelper.Load("../Pomegranate/Salon/Salon.tbin").
That isn't the recommended way to load a mod asset. In particular:
- It won't work if the mod folder structure doesn't exactly match what the developer expects (e.g. MapLoader is running from a subfolder like
Mods/MapLoader-2400-1.0.0/MapLoader
or thePomegranate
folder is renamed). - It won't work for asset keys passed to the game itself, since the game doesn't load content from the
Mods
folder.
Instead, the mod should use the content pack APIs to load the asset. Both of these work fine:
- Loading a content pack asset through the game's content manager:
string assetKey = contentPack.GetActualAssetKey("Salon/townInterior.png"); Texture2D texture = Game1.content.Load<Texture2D>(assetKey);
- Loading a map file (which also adjusts the tilesheet paths automatically so they're loaded from the content pack):
Map map = contentPack.LoadAsset<Map>("Salon/Salon.tbin");