【框架】增加工程构建代码
parent
a5e50a9e1d
commit
8af5e523b2
|
|
@ -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("提示", "项目构建完成!", "确定");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue