From 374ecc1d2aacf7a1f592afec51c7a0ac24e38cd9 Mon Sep 17 00:00:00 2001 From: zhangxl <1062808664@qq.com> Date: Mon, 22 Jul 2024 16:22:32 +0800 Subject: [PATCH] Update CustomBuildTool.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 完善工具 --- .../GameScript/Editor/CustomBuildTool.cs | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Assets/DemoGame/GameScript/Editor/CustomBuildTool.cs b/Assets/DemoGame/GameScript/Editor/CustomBuildTool.cs index ebfc156..5c189ce 100644 --- a/Assets/DemoGame/GameScript/Editor/CustomBuildTool.cs +++ b/Assets/DemoGame/GameScript/Editor/CustomBuildTool.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; @@ -9,6 +10,7 @@ using UnityEditor.Build.Reporting; using UnityEngine; using UnityEngine.SceneManagement; using YooAsset; +using Debug = UnityEngine.Debug; namespace ZEditor { @@ -27,9 +29,9 @@ namespace ZEditor WebGL, } - private static string pc = "Builds/PC"; + private static string pc = "Builds/PC/Game.exe"; private static string webgl = "Builds/WebGL"; - private static string android = "Builds/Android"; + private static string android = "Builds/Android/Game.apk"; #region Win @@ -104,6 +106,8 @@ namespace ZEditor if (summary.result == BuildResult.Succeeded) { + string path = Application.dataPath.Replace("Assets", outputFilePath); + OpenFolder(path); Debug.Log($"{buildTarget} 平台构建完成! "); } else if (summary.result == BuildResult.Cancelled) @@ -121,6 +125,23 @@ namespace ZEditor // Progress.Start("explorer.exe", outputFilePath); } + private static void OpenFolder(string path) + { + // 根据不同的操作系统调用不同的命令来打开文件夹 + switch (Application.platform) + { + case RuntimePlatform.WindowsEditor: + Process.Start("explorer.exe", path); + break; + case RuntimePlatform.OSXEditor: + Process.Start("open", path); + break; + case RuntimePlatform.LinuxEditor: + Process.Start("xdg-open", path); + break; + } + } + // static void ChangeAssetLoadMode(BuildType buildType) { @@ -156,6 +177,8 @@ namespace ZEditor else Debug.LogError("检查一下,打包出问题了!没找到global"); + EditorUtility.SetDirty(gameObject); + Debug.Log($"资源加载模式自动更改为 {playMode}."); } }