编写Editor拓展
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
using UnityEditor.Callbacks;
public class ShaderEditor : MonoBehaviour
{
[OnOpenAssetAttribute(1)]
private static bool OnOpenShader(int instanceID, int line)
{
string assetPath = AssetDatabase.GetAssetPath(instanceID);
if (!string.IsNullOrEmpty(assetPath) && assetPath.EndsWith(".shader"))
{
Process.Start("code", assetPath);
return true; // 返回true表示处理了打开操作
}
return false; // 返回false表示未处理打开操作
}
}