Optimized the speed of simulate build

pull/9/head
hevinci 2022-05-06 20:09:36 +08:00
parent 091758022f
commit 65875b66c2
4 changed files with 35 additions and 10 deletions

View File

@ -89,9 +89,9 @@ namespace YooAsset.Editor
/// <summary>
/// 获取构建的耗时(单位:秒)
/// </summary>
public int GetBuildingSeconds()
public float GetBuildingSeconds()
{
int seconds = (int)(_buildWatch.ElapsedMilliseconds / 1000);
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
return seconds;
}
public void BeginWatch()
@ -139,9 +139,9 @@ namespace YooAsset.Editor
bool succeed = BuildRunner.Run(pipeline, _buildContext);
if (succeed)
Debug.Log($"{buildParameters.BuildMode}模式构建成功!");
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
else
Debug.LogWarning($"{buildParameters.BuildMode}模式构建失败!");
Debug.LogWarning($"{buildParameters.BuildMode} pipeline build failed !");
return succeed;
}
}

View File

@ -45,14 +45,22 @@ namespace YooAsset.Editor
}
/// <summary>
/// 普通日志输出
/// 日志输出
/// </summary>
public static void Log(string info)
{
if (EnableLog)
{
UnityEngine.Debug.Log(info);
}
}
}
/// <summary>
/// 日志输出
/// </summary>
public static void Info(string info)
{
UnityEngine.Debug.Log(info);
}
}
}

View File

@ -12,20 +12,30 @@ namespace YooAsset.Editor
{
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>();
CreateReportFile(buildParameters, buildMapContext);
buildParameters.StopWatch();
var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode != EBuildMode.SimulateBuild)
{
CreateReportFile(buildParameters, buildMapContext);
}
else
{
float buildSeconds = buildParameters.GetBuildingSeconds();
BuildRunner.Info($"Build time consuming {buildSeconds} seconds.");
}
}
private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext)
{
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
BuildReport buildReport = new BuildReport();
buildParameters.StopWatch();
BuildReport buildReport = new BuildReport();
// 概述信息
{
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
buildReport.Summary.BuildTime = DateTime.Now.ToString();
buildReport.Summary.BuildSeconds = buildParameters.GetBuildingSeconds();
buildReport.Summary.BuildSeconds = (int)buildParameters.GetBuildingSeconds();
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
buildReport.Summary.BuildMode = buildParameters.Parameters.BuildMode;
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;

View File

@ -89,6 +89,13 @@ namespace YooAsset.Editor
/// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(AssetBundleCollectorGroup group)
{
// 注意:模拟构建模式下只收集主资源
if (AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild)
{
if (CollectorType != ECollectorType.MainAssetCollector)
return new List<CollectAssetInfo>();
}
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
bool isRawAsset = PackRuleName == nameof(PackRawFile);