From 8af5e523b22eb747c0f1bdcce60476b10fc306cc Mon Sep 17 00:00:00 2001 From: liutao <821580467@qq.com> Date: Tue, 29 Apr 2025 14:19:18 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=A1=86=E6=9E=B6=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=B7=A5=E7=A8=8B=E6=9E=84=E5=BB=BA=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectBuilder/ProjectBuilderWindow.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ProjectNLD/Assets/Editor/ProjectBuilder/ProjectBuilderWindow.cs b/ProjectNLD/Assets/Editor/ProjectBuilder/ProjectBuilderWindow.cs index 12f6820b886..ff471bde434 100644 --- a/ProjectNLD/Assets/Editor/ProjectBuilder/ProjectBuilderWindow.cs +++ b/ProjectNLD/Assets/Editor/ProjectBuilder/ProjectBuilderWindow.cs @@ -51,7 +51,7 @@ namespace ProjectBuilder string[] pathParts = _data.projPath.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); if (pathParts.Length >= 3) { - folderName = string.Join("/", pathParts[pathParts.Length - 3], pathParts[pathParts.Length - 2], pathParts[pathParts.Length - 1]); + folderName = string.Join("/", pathParts[^3], pathParts[^2], pathParts[^1]); } else if (pathParts.Length > 0) { @@ -62,7 +62,29 @@ namespace ProjectBuilder private void _BuildProject() { + // Assets/Code/Scripts/Gameplay + var srcPath = Application.dataPath + "/Code/Scripts/Gameplay"; + var targetPath = _data.projPath + "/Gameplay"; + // 复制所有cs文件到目标路径, 并保持文件夹结构 + if (!System.IO.Directory.Exists(targetPath)) + { + System.IO.Directory.CreateDirectory(targetPath); + } + var files = System.IO.Directory.GetFiles(srcPath, "*.cs", System.IO.SearchOption.AllDirectories); + foreach (var file in files) + { + var relativePath = System.IO.Path.GetRelativePath(srcPath, file); + var targetFile = System.IO.Path.Combine(targetPath, relativePath); + var targetDir = System.IO.Path.GetDirectoryName(targetFile); + if (!System.IO.Directory.Exists(targetDir)) + { + System.IO.Directory.CreateDirectory(targetDir); + } + System.IO.File.Copy(file, targetFile, true); + } + // 弹出提示框 + EditorUtility.DisplayDialog("提示", "项目构建完成!", "确定"); } }