Skip to content

Commit

Permalink
mac corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammin committed Sep 25, 2023
1 parent ca9d482 commit c41a43e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 13 additions & 3 deletions Assets/LDtkUnity/Editor/Utility/LDtkTilesetExporterUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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}\"");
Expand Down Expand Up @@ -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()
{
Expand Down

0 comments on commit c41a43e

Please sign in to comment.