Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tile resolution from asset PixelPerUnit, and plugin interface. #25

Open
BKcore opened this issue Jul 6, 2021 · 2 comments
Open

Tile resolution from asset PixelPerUnit, and plugin interface. #25

BKcore opened this issue Jul 6, 2021 · 2 comments

Comments

@BKcore
Copy link

BKcore commented Jul 6, 2021

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:

  1. Pulling the tile resolution from the Unity Texture Asset
  2. 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;
  }
}
@Cammin
Copy link
Owner

Cammin commented Jul 6, 2021

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 🙂

@sigrist
Copy link

sigrist commented Jul 14, 2022

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

sigrist added a commit to sigrist/LDtkToUnity that referenced this issue Jul 17, 2022
sigrist added a commit to sigrist/LDtkToUnity that referenced this issue Jul 17, 2022
* Added HD version for LDtkRelativeGetterTileTexture
* Update LDtkBuilderTileset to use HD version based on flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants