using System; using System.Diagnostics; using System.IO; using UnityEditor; using Object = UnityEngine.Object; namespace TyphoonFormatCSharp { public class _Editor { private static string _rootPath = null; private static string RootPath { get { if (_rootPath == null) { var p = "Assets/xgame.unity.formatcsharp"; var p2 = "Packages/xgame.unity.formatcsharp"; if (Directory.Exists(p)) { _rootPath = p; } else if (Directory.Exists(p2)) { _rootPath = p2; } else { throw new Exception("找不到插件路径"); } } return _rootPath; } } [MenuItem("Typhoon/FormatCSharp/使用说明")] private static void Readme() { var path = $"{RootPath}/typhoon.unity.formatcsharp使用说明.pdf"; if (!File.Exists(path)) { throw new Exception($"找不到:{path}"); } EditorApplication.ExecuteMenuItem("Window/General/Project"); EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(path)); Process.Start(new FileInfo(path).FullName); } } }