Tile resolution from asset PixelPerUnit, and plugin interface.
Hey,
Following up from a conversation on the LDtk discord.
Turns out you've made a bunch of changes to the project since I grabbed the source, so making a PR wouldn't be trivial. Here's a patch of the changes instead if you want to take a look.
ldtk-asset-proc-changes.patch.txt
This includes 2 changes:
- Pulling the tile resolution from the Unity Texture Asset
- A simple extension pattern to allow defining a path mapper outside of the LDtk source
These changes allow remapping of the tileset art to a different file, with a different tile resolution, allowing the use of HD tilesets (keeping low-res tilesets in LDtk which doesn't support high-res tiles).
Here's what the path mapper looks like on my side:
[InitializeOnLoad]
public static class AssetProcessingExtensionsInitializer {
static AssetProcessingExtensionsInitializer() {
Debug.Log("AssetProcessingExtensionsInitializer");
AssetProcessingExtensions.RegisterAssetPathMapper(new AssetPathMapper());
}
}
public class AssetPathMapper : IAssetPathMapper {
public string MapAssetPath(string path) {
var outPath = path;
if (outPath.EndsWith("SD.png")) {
var hd = outPath.Replace("SD.png", "HD.png");
if (File.Exists(hd)) {
outPath = hd;
}
}
if (path != outPath) {
Debug.Log($"Remapped {path} to {outPath}");
}
return outPath;
}
}
Yeah, this looks very cool. I may implement this sometime, in case this can be helpful for anyone else in the same situation.
Thanks for providing your solution to rerouting paths 🙂
This issue is a little old, but it would be a great feature. Working with small resolution in LDTK and then the possibility to replace with high resolution assets when importing in Unity would be awesome
+1 to implement this feature