实现代码:
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
public class UsePSToOpen
{
private const string psPath = "D:\\Program Files\\Adobe Photoshop 2021\\Photoshop.exe";
[MenuItem("Assets/Use PS to Open #&p")]
public static void UsePSToOpenPhoto()
{
int instanceID = Selection.activeInstanceID;
string path = AssetDatabase.GetAssetPath(EditorUtility.InstanceIDToObject(instanceID));
string name = (Application.dataPath + "/" + path.Replace("Assets/", "")).Replace("/", "\\");
ProcessStartInfo startInfo = new ProcessStartInfo()
{
FileName = psPath,
Arguments = name,
};
Process process = new Process() { StartInfo = startInfo };
process.Start();
}
}
使用方法: 1.脚本放入Editor文件夹 2.图像文件右键,选择“Use PS to Open”即可。或选中后按快捷键 Shift+Alt+P
|