mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-10 06:34:16 +00:00
log progress periodically
This commit is contained in:
parent
e6ce4c16c9
commit
653bf4c7ae
2 changed files with 12 additions and 1 deletions
|
@ -23,6 +23,8 @@ namespace SanAndreasUnity.Editor
|
|||
|
||||
public bool FinishedSuccessfully { get; private set; } = false;
|
||||
|
||||
public bool LogProgressPeriodically { get; set; } = false;
|
||||
|
||||
|
||||
|
||||
public NavMeshGenerator(NavMeshData navMeshData)
|
||||
|
@ -190,6 +192,8 @@ namespace SanAndreasUnity.Editor
|
|||
new Bounds(cell.transform.position, new Vector3(cell.WorldSize, (cell.interiorHeightOffset + 1000f + 300f) * 2f, cell.WorldSize)));
|
||||
|
||||
var etaMeasurer = new ETAMeasurer(2f);
|
||||
var logStopwatch = System.Diagnostics.Stopwatch.StartNew();
|
||||
var totalUpdateTimeStopwatch = System.Diagnostics.Stopwatch.StartNew();
|
||||
|
||||
while (!asyncOperation.isDone)
|
||||
{
|
||||
|
@ -197,6 +201,12 @@ namespace SanAndreasUnity.Editor
|
|||
|
||||
etaMeasurer.UpdateETA(asyncOperation.progress);
|
||||
|
||||
if (this.LogProgressPeriodically && logStopwatch.Elapsed.TotalSeconds > 20)
|
||||
{
|
||||
Debug.Log($"Updating nav mesh... ETA: {etaMeasurer.ETA}, progress: {asyncOperation.progress}, elapsed: {totalUpdateTimeStopwatch.Elapsed}");
|
||||
logStopwatch.Restart();
|
||||
}
|
||||
|
||||
if (EditorUtils.DisplayPausableProgressBar("", $"Updating nav mesh... ETA: {etaMeasurer.ETA}", asyncOperation.progress))
|
||||
yield break;
|
||||
}
|
||||
|
@ -210,7 +220,7 @@ namespace SanAndreasUnity.Editor
|
|||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
DisplayMessage("Nav mesh generation complete !");
|
||||
DisplayMessage($"Nav mesh generation complete !\r\nElapsed time: {totalUpdateTimeStopwatch.Elapsed}");
|
||||
|
||||
this.FinishedSuccessfully = true;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ namespace SanAndreasUnity.Editor
|
|||
// now fire up NavMeshGenerator
|
||||
|
||||
var navMeshGenerator = new NavMeshGenerator(null);
|
||||
navMeshGenerator.LogProgressPeriodically = true;
|
||||
|
||||
var navMeshBuildSettings = NavMesh.GetSettingsByID(0);
|
||||
navMeshBuildSettings.maxJobWorkers = CmdLineUtils.TryGetUshortArgument("navMeshGenerationMaxJobWorkers", out ushort maxJobWorkers) ? maxJobWorkers : (uint)2;
|
||||
|
|
Loading…
Reference in a new issue