using System.Diagnostics; using UnityEditor; using UnityEngine; namespace TEngine.Editor { /// /// 打开文件夹相关的实用函数。 /// public static class OpenFolderHelper { /// /// 打开 Data Path 文件夹。 /// [MenuItem("TEngine/Open Folder/Data Path", false, 10)] public static void OpenFolderDataPath() { Execute(Application.dataPath); } /// /// 打开 Persistent Data Path 文件夹。 /// [MenuItem("TEngine/Open Folder/Persistent Data Path", false, 11)] public static void OpenFolderPersistentDataPath() { Execute(Application.persistentDataPath); } /// /// 打开 Streaming Assets Path 文件夹。 /// [MenuItem("TEngine/Open Folder/Streaming Assets Path", false, 12)] public static void OpenFolderStreamingAssetsPath() { Execute(Application.streamingAssetsPath); } /// /// 打开 Temporary Cache Path 文件夹。 /// [MenuItem("TEngine/Open Folder/Temporary Cache Path", false, 13)] public static void OpenFolderTemporaryCachePath() { Execute(Application.temporaryCachePath); } #if UNITY_2018_3_OR_NEWER /// /// 打开 Console Log Path 文件夹。 /// [MenuItem("TEngine/Open Folder/Console Log Path", false, 14)] public static void OpenFolderConsoleLogPath() { Execute(System.IO.Path.GetDirectoryName(Application.consoleLogPath)); } #endif /// /// 打开指定路径的文件夹。 /// /// 要打开的文件夹的路径。 public static void Execute(string folder) { folder = $"\"{folder}\""; switch (Application.platform) { case RuntimePlatform.WindowsEditor: Process.Start("Explorer.exe", folder.Replace('/', '\\')); break; case RuntimePlatform.OSXEditor: Process.Start("open", folder); break; default: throw new System.Exception($"Not support open folder on '{Application.platform}' platform."); } } } }