Unity 版本
Unity 2021.3.15f1
问题描述
Unity 发布PC 平台软件时,比旧版本Unity 发布多创建了一个ProductName_BurstDebugInformation_DoNotShip 文件夹,文件夹里是一个.txt 文本,用来查看和调试当前包的信息,但偶有不需要这个文件夹存在的情况。查过之后发现ProductName_BurstDebugInformation_DoNotShip 文件夹是可忽略或删除的,言外之意就是可以在发布成功后手动删除,但每次发布都手动删除比较麻烦。
解决
通过设置取消创建
Question - Fail_BurstDebugInformation_DoNotShip - Unity Forumhttps://forum.unity.com/threads/fail_burstdebuginformation_donotship.1447171/编辑器里Edit → Project Settings → Burst AOT Settings 找到Enable Burst Compilation 并取消勾选可以实现在发布时不创建ProductName_BurstDebugInformation_DoNotShip 文件夹。
但是Unity 官方技术人员表示这不是个良方,取消Brust 会导致发布后的软件运行变慢。
发布成功后自动删除
BurstDebugInformation_DoNotShip in builds - Unity Forumhttps://forum.unity.com/threads/burstdebuginformation_donotship-in-builds.1172273/不能取消Burst 那就只能回到创建后再删除,使用代码实现在发布成功后自动删除避免了每次发布都要手动删除的麻烦。
try
{
string applicationName = Path.GetFileNameWithoutExtension(outputPath);
string outputFolder = Path.GetDirectoryName(outputPath);
Assert.IsNotNull(outputFolder);
outputFolder = Path.GetFullPath(outputFolder);
//Delete Burst Debug Folder
string burstDebugInformationDirectoryPath = Path.Combine(outputFolder, ${applicationName}_BurstDebugInformation_DoNotShip");
if (Directory.Exists(burstDebugInformationDirectoryPath))
{
Debug.Log($" > Deleting Burst debug information folder at path '{burstDebugInformationDirectoryPath}'...");
Directory.Delete(burstDebugInformationDirectoryPath, true);
}
}
catch (Exception e)
{
Debug.LogWarning($"An unexpected exception occurred while performing build cleanup: {e}");
}
把脚本放入Editor 文件夹下再进行发布即可