Skip to content

Commit

Permalink
* AssetContextMenus: better compatibility with Paint.NET, Krita and B…
Browse files Browse the repository at this point in the history
…lender
  • Loading branch information
NibbleByte committed Oct 4, 2023
1 parent d326807 commit 10792b6
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions Editor/AssetContextMenus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,21 @@ private static bool EditWithTextValidate()

[MenuItem("Assets/Edit With/Paint.NET", false, EditWith_MenuItemPriorityStart + 20)]
private static void EditWithPaintDotNet()
=> EditWithApp("paintdotnet.exe", GetPathsOfAssetsJoined(Selection.objects, false));

{
if (TryEditWithApp("paint.net.1", GetPathsOfAssetsJoined(Selection.objects, false)))
return;

EditWithApp("paintdotnet.exe", GetPathsOfAssetsJoined(Selection.objects, false));
}

[MenuItem("Assets/Edit With/Krita", false, EditWith_MenuItemPriorityStart + 22)]
private static void EditWithKrita()
=> EditWithApp("krita.exe", GetPathsOfAssetsJoined(Selection.objects, false));
{
if (TryEditWithApp("Krita.Document", GetPathsOfAssetsJoined(Selection.objects, false)))
return;

EditWithApp("krita.exe", GetPathsOfAssetsJoined(Selection.objects, false));
}

[MenuItem("Assets/Edit With/Photoshop", false, EditWith_MenuItemPriorityStart + 24)]
private static void EditWithPhotoshop()
Expand Down Expand Up @@ -205,17 +215,22 @@ private static void EditWithBlender()
AssetDatabase.OpenAsset(Selection.objects[0]);
return;
}

// Assume this is fbx or other model file. It can't be opened directly, it needs to be imported.
EditWithApp("blender.exe", $"--python-expr \"" + // start python expression.
// Idea by: https://blog.kikicode.com/2018/12/double-click-fbx-files-to-import-to.html
string args = $"--python-expr \"" + // start python expression.

$"import bpy;\n" +
//$"bpy.context.preferences.view.show_splash=False;\n" + // This is persistent so skip it.
"bpy.ops.scene.new(type='EMPTY');\n" +
$"bpy.ops.import_scene.fbx(filepath=r'{fullPath}');\n" +
$"import bpy;\n" +
//$"bpy.context.preferences.view.show_splash=False;\n" + // This is persistent so skip it.
"bpy.ops.scene.new(type='EMPTY');\n" +
$"bpy.ops.import_scene.fbx(filepath=r'{fullPath}');\n" +

$"\"" // End python expression
); // Idea by: https://blog.kikicode.com/2018/12/double-click-fbx-files-to-import-to.html
$"\""; // End python expression

if (TryEditWithApp("blendfile", args))
return;

EditWithApp("blender.exe", args);
}


Expand Down

0 comments on commit 10792b6

Please sign in to comment.