{"author_link":"\/users\/swen","author_name":"Swen","author_uid":"swen","comments":[],"epoch":1556380212,"event":"LD44","format":"md","ldjam_node_id":150512,"likes":7,"metadata":{"p_key":"129406","p_author":"Swen","p_authorkey":"1050559","p_urlkey":"345560","p_title":"Aseprite tooling for Unity","p_cat":"LDJam ","p_event":"LD44","p_time":"1556380212","p_likes":"7","p_comments":"0","p_status":"WAYBACK","us_key":"1050559","us_name":"Swen","us_username":"swen","event_start":"1556236800","event_key":"75","event_name":"LD 44"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD44","removed_author":false},"_superparent":139254,"_trust":10,"author":50559,"body":"Just created a menu option in Unity to export selected .aseprite files to .png's (see gif below).\n![aseprite_tool.gif](\/\/\/raw\/f75\/c\/z\/2093d.gif)\n\nMight be handy for other jammers using Unity and Aseprite, feel free to tweak and use :)\n\nMake sure to put it in a folder called `Editor`, so that Unity knows that it is an editor extension.\n\nNote: This might only work on Windows because of `Process.Start`, but I'm not sure.\n```csharp\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing UnityEditor;\nusing UnityEngine;\n\npublic class AsepriteExporter {\n  public readonly static string AsepritePath = @\"C:\\Program Files (x86)\\Steam\\steamapps\\common\\Aseprite\\Aseprite.exe\"; \/\/ Path to Aseprite executable (filled with example)\n  public readonly static string ExportAtRelativePath = @\"Export\"; \/\/ Files will be exported to this folder (e.g. `Assets\/player.aseprite` -> `Assets\/Export\/player.png`\n\n  [MenuItem(\"Assets\/Aseprite\/Export Selection To PNG\")]\n  private static void ExportAsepriteFilesToPng() {\n    var selectedAsepriteFilePaths = GetAsepriteFilePaths(Selection.objects);\n    \n    var asepriteFiles = selectedAsepriteFilePaths\n      .Select((f) => Path.GetFileName(f))\n      .OrderBy((a) => a)\n      .Aggregate((a, b) => a + \"\\n- \" + b);\n\n    var hasConfirmed = EditorUtility.DisplayDialog(\n      \"Aseprite export\",\n      string.Format(\"Are you sure you want to export the aseprite files:\\n- {0}\", asepriteFiles),\n      \"Ok\",\n      \"Cancel\");\n\n    if (!hasConfirmed) {\n      return;\n    }\n\n    foreach (var selectedAsepriteFilePath in selectedAsepriteFilePaths) {\n      var sourceAsepriteFullFilePath = Path.GetFullPath(selectedAsepriteFilePath);\n      var targetFileNameWithoutExtension = Path.GetFileNameWithoutExtension(sourceAsepriteFullFilePath);\n      var sourceAsepriteDirectory = Path.GetDirectoryName(sourceAsepriteFullFilePath);\n      var targetFilePath = Path.Combine(sourceAsepriteDirectory, ExportAtRelativePath, targetFileNameWithoutExtension) + \".png\";\n\n      var processStartInfo = new ProcessStartInfo(AsepritePath) {\n        Arguments = string.Format(\"--batch {0} --save-as {1}\", sourceAsepriteFullFilePath, targetFilePath),\n        UseShellExecute = true,\n        CreateNoWindow = false\n      };\n\n      var process = Process.Start(processStartInfo);\n      process.WaitForExit();\n      UnityEngine.Debug.LogFormat(\"[Aseprite Exporter] Exported {0} in {1}\", Path.GetFileName(selectedAsepriteFilePath), selectedAsepriteFilePath);\n    }\n\n    AssetDatabase.SaveAssets();\n    AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);\n  }\n\n  private static IEnumerable<string> GetAsepriteFilePaths(Object[] objects) {\n    return objects\n     .Select(o => AssetDatabase.GetAssetPath(o)) \/\/GetInstanceID\n     .Where(IsAsepriteFile);\n  }\n\n  private static bool IsAsepriteFile(string filePath) {\n    var extension = Path.GetExtension(filePath).Trim('.').ToLower();\n    return extension == \"ase\" || extension == \"aseprite\";\n  }\n}\n\n```","comments":1,"comments-timestamp":"2019-04-27T15:56:06Z","created":"2019-04-27T15:44:43Z","files":[],"files-timestamp":0,"id":150512,"love":7,"love-timestamp":"2019-04-27T17:53:46Z","meta":[],"modified":"2019-04-27T17:53:46Z","name":"Aseprite tooling for Unity","node-timestamp":"2019-04-27T15:54:09Z","parent":140825,"parents":[1,5,9,139254,140825],"path":"\/events\/ludum-dare\/44\/devils-circus\/aseprite-tooling-for-unity","published":"2019-04-27T15:50:12Z","scope":"public","slug":"aseprite-tooling-for-unity","subsubtype":"","subtype":"","type":"post","version":436550},"node_metadata":{"n_key":"150512","n_urlkey":"345560","n_parent":"140825","n_path":"\/events\/ludum-dare\/44\/devils-circus\/aseprite-tooling-for-unity","n_slug":"aseprite-tooling-for-unity","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"50559","n_created":"1556379883","n_modified":"1556387626","n_version":"436550","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/44\/devils-circus\/aseprite-tooling-for-unity","text":"Just created a menu option in Unity to export selected .aseprite files to .png's (see gif below).\n![aseprite_tool.gif](\/\/\/raw\/f75\/c\/z\/2093d.gif)\n\nMight be handy for other jammers using Unity and Aseprite, feel free to tweak and use :)\n\nMake sure to put it in a folder called `Editor`, so that Unity knows that it is an editor extension.\n\nNote: This might only work on Windows because of `Process.Start`, but I'm not sure.\n```csharp\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing UnityEditor;\nusing UnityEngine;\n\npublic class AsepriteExporter {\n  public readonly static string AsepritePath = @\"C:\\Program Files (x86)\\Steam\\steamapps\\common\\Aseprite\\Aseprite.exe\"; \/\/ Path to Aseprite executable (filled with example)\n  public readonly static string ExportAtRelativePath = @\"Export\"; \/\/ Files will be exported to this folder (e.g. `Assets\/player.aseprite` -> `Assets\/Export\/player.png`\n\n  [MenuItem(\"Assets\/Aseprite\/Export Selection To PNG\")]\n  private static void ExportAsepriteFilesToPng() {\n    var selectedAsepriteFilePaths = GetAsepriteFilePaths(Selection.objects);\n    \n    var asepriteFiles = selectedAsepriteFilePaths\n      .Select((f) => Path.GetFileName(f))\n      .OrderBy((a) => a)\n      .Aggregate((a, b) => a + \"\\n- \" + b);\n\n    var hasConfirmed = EditorUtility.DisplayDialog(\n      \"Aseprite export\",\n      string.Format(\"Are you sure you want to export the aseprite files:\\n- {0}\", asepriteFiles),\n      \"Ok\",\n      \"Cancel\");\n\n    if (!hasConfirmed) {\n      return;\n    }\n\n    foreach (var selectedAsepriteFilePath in selectedAsepriteFilePaths) {\n      var sourceAsepriteFullFilePath = Path.GetFullPath(selectedAsepriteFilePath);\n      var targetFileNameWithoutExtension = Path.GetFileNameWithoutExtension(sourceAsepriteFullFilePath);\n      var sourceAsepriteDirectory = Path.GetDirectoryName(sourceAsepriteFullFilePath);\n      var targetFilePath = Path.Combine(sourceAsepriteDirectory, ExportAtRelativePath, targetFileNameWithoutExtension) + \".png\";\n\n      var processStartInfo = new ProcessStartInfo(AsepritePath) {\n        Arguments = string.Format(\"--batch {0} --save-as {1}\", sourceAsepriteFullFilePath, targetFilePath),\n        UseShellExecute = true,\n        CreateNoWindow = false\n      };\n\n      var process = Process.Start(processStartInfo);\n      process.WaitForExit();\n      UnityEngine.Debug.LogFormat(\"[Aseprite Exporter] Exported {0} in {1}\", Path.GetFileName(selectedAsepriteFilePath), selectedAsepriteFilePath);\n    }\n\n    AssetDatabase.SaveAssets();\n    AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);\n  }\n\n  private static IEnumerable<string> GetAsepriteFilePaths(Object[] objects) {\n    return objects\n     .Select(o => AssetDatabase.GetAssetPath(o)) \/\/GetInstanceID\n     .Where(IsAsepriteFile);\n  }\n\n  private static bool IsAsepriteFile(string filePath) {\n    var extension = Path.GetExtension(filePath).Trim('.').ToLower();\n    return extension == \"ase\" || extension == \"aseprite\";\n  }\n}\n\n```","title":"Aseprite tooling for Unity","wayback_source":[]}