diff --git a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_1_basic.ldtk b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_1_basic.ldtk index dd816c073..f6b5b3c9f 100644 --- a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_1_basic.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_1_basic.ldtk @@ -36,7 +36,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "IntGrid layers can paint tiles automatically using simple RULE SETS.\n\n - Press [SHIFT + R] to toggle auto-layer rendering\n - Click on the RULES button on the left to see/edit rules.", - "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "Manual" }], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { diff --git a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_2_stamps.ldtk b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_2_stamps.ldtk index 3bb189613..43360fb39 100644 --- a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_2_stamps.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_2_stamps.ldtk @@ -36,7 +36,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "\"STAMPS\" are groups of multiple tiles that are generated by RULES.\n\nClick on the RULES button on the left to see them.", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -341,4 +341,4 @@ ], "worlds": [], "dummyWorldIid": "c9259b80-c640-11ed-ad34-65fb5dfe1c19" -} \ No newline at end of file +} diff --git a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_3_Mosaic.ldtk b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_3_Mosaic.ldtk index 4b819fcd6..4b9c437e0 100644 --- a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_3_Mosaic.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_3_Mosaic.ldtk @@ -36,7 +36,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "This example demonstrates the use of rules to create complex but dynamic mosaics.", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -1646,4 +1646,4 @@ ], "worlds": [], "dummyWorldIid": "c9361640-c640-11ed-ad34-af90bc56df47" -} \ No newline at end of file +} diff --git a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_4_Assistant.ldtk b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_4_Assistant.ldtk index 61c2ddc42..811e78a69 100644 --- a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_4_Assistant.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_4_Assistant.ldtk @@ -36,7 +36,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "In this example, the rules are automatically created and managed by the rule \"Assistant\".\n\nTo open it, click on the \"Rules\" button on the left, then \"Edit\" on the \"Walls\" group.", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -877,4 +877,4 @@ ], "worlds": [], "dummyWorldIid": "c9449530-c640-11ed-ad34-138bedf36840" -} \ No newline at end of file +} diff --git a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_5_Advanced.ldtk b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_5_Advanced.ldtk index 4dd6f7472..c37546765 100644 --- a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_5_Advanced.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_5_Advanced.ldtk @@ -36,7 +36,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "Rules can be used to render various biome elements, such as Dirt, Water or Lava.\n\nPress [SHIFT + R] to toggle auto-layers rendering", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -2792,4 +2792,4 @@ ], "worlds": [], "dummyWorldIid": "c9533b30-c640-11ed-ad34-4b074b658372" -} \ No newline at end of file +} diff --git a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_6_OptionalRules.ldtk b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_6_OptionalRules.ldtk index b9444afb5..64c35e5ba 100644 --- a/Assets/LDtkUnity/Samples~/Samples/AutoLayers_6_OptionalRules.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/AutoLayers_6_OptionalRules.ldtk @@ -36,7 +36,7 @@ "backupRelPath": null, "levelNamePattern": "level_x%gx,y%gy", "tutorialDesc": "This sample shows how to use OPTIONAL rules to create biomes and variations easily.\n\nClick the \"RULES\" button on the left to see all the rule groups. Some groups are BLUE: they are optional which means they are disabled by default, and can be enabled only in specific levels.", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -7759,4 +7759,4 @@ ], "worlds": [], "dummyWorldIid": "7b3c9d60-c640-11ed-9217-5d5a1e1cd04a" -} \ No newline at end of file +} diff --git a/Assets/LDtkUnity/Samples~/Samples/Entities.ldtk b/Assets/LDtkUnity/Samples~/Samples/Entities.ldtk index ea4ec64ea..292e774a0 100644 --- a/Assets/LDtkUnity/Samples~/Samples/Entities.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/Entities.ldtk @@ -44,7 +44,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "Entities can be used to represent any gameplay element, such as player, enemies, items etc.\n\nThey can have many kind of customizable properties, including arrays, enums or coordinates.", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -4563,4 +4563,4 @@ ], "worlds": [], "dummyWorldIid": "f310fef0-7820-11ed-9859-6530dfcbabd7" -} \ No newline at end of file +} diff --git a/Assets/LDtkUnity/Samples~/Samples/SeparateLevelFiles.ldtk b/Assets/LDtkUnity/Samples~/Samples/SeparateLevelFiles.ldtk index 1a320cf3a..2ec2799fa 100644 --- a/Assets/LDtkUnity/Samples~/Samples/SeparateLevelFiles.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/SeparateLevelFiles.ldtk @@ -36,7 +36,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "In this example, the levels are stored in separate files, in a subfolder. \n\nThis is fully transparent from the editor perspective.", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -143,4 +143,4 @@ ], "worlds": [], "dummyWorldIid": "c9a37e10-c640-11ed-ad34-4391c8dfabdd" -} \ No newline at end of file +} diff --git a/Assets/LDtkUnity/Samples~/Samples/Test_file_for_API_showing_all_features.ldtk b/Assets/LDtkUnity/Samples~/Samples/Test_file_for_API_showing_all_features.ldtk index 59a5e60fd..d63b690d7 100644 --- a/Assets/LDtkUnity/Samples~/Samples/Test_file_for_API_showing_all_features.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/Test_file_for_API_showing_all_features.ldtk @@ -49,7 +49,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "This file can be used to check if an API supports LDtk file format properly. \n\nIt uses most important LDtk features.", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -3204,4 +3204,4 @@ ], "worlds": [], "dummyWorldIid": "c9b00130-c640-11ed-ad34-57d0f1a6d3a2" -} \ No newline at end of file +} diff --git a/Assets/LDtkUnity/Samples~/Samples/Typical_TopDown_example.ldtk b/Assets/LDtkUnity/Samples~/Samples/Typical_TopDown_example.ldtk index 0ac9ac256..c4ffe6f53 100644 --- a/Assets/LDtkUnity/Samples~/Samples/Typical_TopDown_example.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/Typical_TopDown_example.ldtk @@ -44,7 +44,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "This example uses a combination of Auto-Layers with a vertical offset of -16px on the \"Wall_tops\" layer. This trick allows rendering of a \"top-down\" level with a minimal amount of tiles (and work).\n\nPress [SHIFT + A] to toggle \"Single Layer Mode\", and see what each layer really contains.\n\nPress [SHIFT + R] to toggle rendering of rules based layers.", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -4621,4 +4621,4 @@ ], "worlds": [], "dummyWorldIid": "c9ef2d10-c640-11ed-ad34-f553e1d803f9" -} \ No newline at end of file +} diff --git a/Assets/LDtkUnity/Samples~/Samples/WorldMap_Free_layout.ldtk b/Assets/LDtkUnity/Samples~/Samples/WorldMap_Free_layout.ldtk index 602ae9808..c1a052525 100644 --- a/Assets/LDtkUnity/Samples~/Samples/WorldMap_Free_layout.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/WorldMap_Free_layout.ldtk @@ -36,7 +36,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "In \"Free\" world layout, levels are positionned freely in the 2D space.\n\nIn this example, some are even in different world layers (ie. above and behind). Use [PAGE UP] and [PAGE DOWN] to move between world layers.", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -14945,4 +14945,4 @@ ], "worlds": [], "dummyWorldIid": "ca0e9bf0-c640-11ed-ad34-5d947c1a0a9f" -} \ No newline at end of file +} diff --git a/Assets/LDtkUnity/Samples~/Samples/WorldMap_GridVania_layout.ldtk b/Assets/LDtkUnity/Samples~/Samples/WorldMap_GridVania_layout.ldtk index d4a24d622..3d8fd63d8 100644 --- a/Assets/LDtkUnity/Samples~/Samples/WorldMap_GridVania_layout.ldtk +++ b/Assets/LDtkUnity/Samples~/Samples/WorldMap_GridVania_layout.ldtk @@ -44,7 +44,7 @@ "backupRelPath": null, "levelNamePattern": "%world_Level_%idx", "tutorialDesc": "In Gridvania world layouts, levels are organized on a large grid.\nPress [W] to switch to World mode.\nIn this example, some are even in different world layers (ie. above and behind). Use [PAGE UP] and [PAGE DOWN] to move between world layers.", - "customCommands": [], + "customCommands": [{ "command": "../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe", "when": "AfterSave" }], "flags": ["UseMultilinesType"], "defs": { "layers": [ { @@ -33243,4 +33243,4 @@ ], "worlds": [], "dummyWorldIid": "ca3d7420-c640-11ed-ad34-5f1a115c4cf3" -} \ No newline at end of file +} diff --git a/Assets/Tools/SampleUpdater.cs b/Assets/Tools/SampleUpdater.cs index f496a203c..ebbed47a0 100644 --- a/Assets/Tools/SampleUpdater.cs +++ b/Assets/Tools/SampleUpdater.cs @@ -62,9 +62,39 @@ private static void CopyFilesRecursively(string sourcePath, string targetPath) //ignore the thumbnails continue; } + + string dest = newPath.Replace(sourcePath, targetPath); + File.Copy(newPath, dest, true); + ModifyCommandToWork(dest); + } + } + + private static void ModifyCommandToWork(string newPath) + { + if (Path.GetExtension(newPath) != ".ldtk") + { + return; + } + Debug.Log(newPath); + + const string before = @"""customCommands"": [],"; + const string after = @"""customCommands"": [{ ""command"": ""../../../Library/LDtkTilesetExporter/ExportTilesetDefinition.exe"", ""when"": ""AfterSave"" }],"; - File.Copy(newPath, newPath.Replace(sourcePath, targetPath), true); + string[] lines = File.ReadAllLines(newPath); + Debug.Log(lines.Length); + + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + + if (line.Contains(before)) + { + Debug.Log("REPLACE"); + lines[i] = line.Replace(before, after); + } } + + File.WriteAllLines(newPath, lines); } } }