diff --git a/Assets/LDtkUnity/Editor/CustomEditor/Importer/LDtkEditorCommandUpdater.cs b/Assets/LDtkUnity/Editor/CustomEditor/Importer/LDtkEditorCommandUpdater.cs index a59fbc90b..0c8779e12 100644 --- a/Assets/LDtkUnity/Editor/CustomEditor/Importer/LDtkEditorCommandUpdater.cs +++ b/Assets/LDtkUnity/Editor/CustomEditor/Importer/LDtkEditorCommandUpdater.cs @@ -21,17 +21,24 @@ public LDtkEditorCommandUpdater(string projectPath) private string GetCommand() { string fromPath = LDtkPathUtility.AssetsPathToAbsolutePath(ProjectPath); + + +#if UNITY_EDITOR_OSX + //if mac, we're launching a different file that's meant to launch the exe + string appPath = LDtkTilesetExporterUtil.PathToMacSh(); +#else string appPath = LDtkTilesetExporterUtil.PathToExe(); - - var relPath = LDtkPathUtility.GetRelativePath(fromPath, appPath); - //backslashes break deserialization - relPath = LDtkPathUtility.CleanPathSlashes(relPath); +#endif + var commandContent = LDtkPathUtility.GetRelativePath(fromPath, appPath); + //backslashes break deserialization + commandContent = LDtkPathUtility.CleanPathSlashes(commandContent); + //Debug.Log($"fromPath {fromPath}"); //Debug.Log($"appPath {appPath}"); //Debug.Log($"relPath {relPath}"); - return relPath; + return commandContent; } public void TryDrawFixButton(LdtkJson data) diff --git a/Assets/LDtkUnity/Editor/Utility/LDtkTilesetExporterUtility.cs b/Assets/LDtkUnity/Editor/Utility/LDtkTilesetExporterUtility.cs index ab7557fe6..fafbad108 100644 --- a/Assets/LDtkUnity/Editor/Utility/LDtkTilesetExporterUtility.cs +++ b/Assets/LDtkUnity/Editor/Utility/LDtkTilesetExporterUtility.cs @@ -10,15 +10,14 @@ internal static class LDtkTilesetExporterUtil { private const string EXPORT_ZIP = "LDtkTilesetExporter.zip"; private const string EXPORT_APP = "ExportTilesetDefinition.exe"; + private const string MAC_APP = "ExportTilesetDefinitionMac.sh"; //[MenuItem("UnzipToProject/Unzip")] public static void UnzipToLibrary() { string pathToZip = PathToZip(); - string destDir = PathToLibraryDir(); - LDtkPathUtility.TryCreateDirectory(destDir); if (Directory.Exists(destDir)) { @@ -35,8 +34,14 @@ public static void UnzipToLibrary() ZipUtil.Extract(pathToZip, destDir); #if UNITY_EDITOR_OSX + string pathToExe = PathToExe(); + //on mac, the app needs some permission. Use "sudo chmod +x" - Process.Start("/bin/bash", $"-c \" chmod +x {PathToExe()}\" "); + Process.Start("/bin/bash", $"-c \" chmod +x {pathToExe}\" "); + + //if mac, we're creating a bonus file that's meant to launch the exe through mono + string shContent = $"Library/Frameworks/Mono.framework/Versions/Current/Commands/mono {pathToExe}"; + File.WriteAllText(PathToMacSh(), shContent); #endif LDtkDebug.Log($"Extracted the tileset export app to \"{destDir}\""); @@ -77,6 +82,11 @@ public static string PathToExe() string exePath = Path.Combine(PathToLibraryDir(), EXPORT_APP); return exePath; } + public static string PathToMacSh() + { + string exePath = Path.Combine(PathToLibraryDir(), MAC_APP); + return exePath; + } public static bool GetAppUpToDate() {