63 lines
1.9 KiB
C#
63 lines
1.9 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.IO;
|
|||
|
|
using UnityEditor.Build;
|
|||
|
|
using UnityEditor.Build.Reporting;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
public class VirtualFPostProcess : IPostprocessBuildWithReport
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>Խ<EFBFBD><D4BD>Խ<EFBFBD><D4BD>ִ<EFBFBD>У<EFBFBD>
|
|||
|
|
public int callbackOrder => 0;
|
|||
|
|
|
|||
|
|
// <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD>ִ<EFBFBD><D6B4>
|
|||
|
|
public void OnPostprocessBuild(BuildReport report)
|
|||
|
|
{
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1>Ŀ<EFBFBD><C4BF>Ŀ¼·<C2BC><C2B7>
|
|||
|
|
string projectPath = Application.dataPath;
|
|||
|
|
|
|||
|
|
// <20><>ȡData<74>ļ<EFBFBD><C4BC>е<EFBFBD>·<EFBFBD><C2B7>
|
|||
|
|
string dataFolderPath = Path.Combine(projectPath, "../Data");
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
|
|||
|
|
string buildOutputPath = report.summary.outputPath;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>Data<74>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (Directory.Exists(dataFolderPath))
|
|||
|
|
{
|
|||
|
|
// <20><>Data<74>ļ<EFBFBD><C4BC>и<EFBFBD><D0B8>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>Ŀ¼
|
|||
|
|
string targetDataPath = Path.Combine(buildOutputPath, "Data");
|
|||
|
|
CopyDirectory(dataFolderPath, targetDataPath);
|
|||
|
|
Debug.Log($"Data folder copied to build output directory: {targetDataPath}");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Debug.LogWarning("Data folder not found at: " + dataFolderPath);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ݹ鸴<DDB9><E9B8B4><EFBFBD>ļ<EFBFBD><C4BC>еĸ<D0B5><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
|
private void CopyDirectory(string sourceDir, string destinationDir)
|
|||
|
|
{
|
|||
|
|
// ȷ<><C8B7>Ŀ<EFBFBD><C4BF>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>
|
|||
|
|
if (!Directory.Exists(destinationDir))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(destinationDir);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ԴĿ¼<C4BF>е<EFBFBD><D0B5>ļ<EFBFBD>
|
|||
|
|
foreach (string file in Directory.GetFiles(sourceDir))
|
|||
|
|
{
|
|||
|
|
string destFile = Path.Combine(destinationDir, Path.GetFileName(file));
|
|||
|
|
File.Copy(file, destFile, true); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ԴĿ¼<C4BF>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
|
foreach (string subDir in Directory.GetDirectories(sourceDir))
|
|||
|
|
{
|
|||
|
|
string destSubDir = Path.Combine(destinationDir, Path.GetFileName(subDir));
|
|||
|
|
CopyDirectory(subDir, destSubDir); // <20>ݹ鸴<DDB9><E9B8B4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|