修复编译错误
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using PathBerserker2d;
|
||||
@@ -11,6 +12,12 @@ namespace BaseGames.Editor
|
||||
/// </summary>
|
||||
public static class NavSurfaceBakeShortcut
|
||||
{
|
||||
// NavSurface.StartBakeJob() 和 NavSurface.BakeJob 均为 internal,通过反射访问。
|
||||
private static readonly MethodInfo s_startBakeJobMethod =
|
||||
typeof(NavSurface).GetMethod("StartBakeJob", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
private static readonly PropertyInfo s_bakeJobProp =
|
||||
typeof(NavSurface).GetProperty("BakeJob", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
[MenuItem("BaseGames/Tools/Bake All NavSurfaces %#b", priority = 100)]
|
||||
public static void BakeAll()
|
||||
{
|
||||
@@ -26,7 +33,7 @@ namespace BaseGames.Editor
|
||||
{
|
||||
if (surface == null) continue;
|
||||
|
||||
surface.StartBakeJob();
|
||||
s_startBakeJobMethod?.Invoke(surface, null);
|
||||
EditorApplication.update -= MakeWatcher(surface);
|
||||
EditorApplication.update += MakeWatcher(surface);
|
||||
count++;
|
||||
@@ -49,16 +56,28 @@ namespace BaseGames.Editor
|
||||
EditorApplication.CallbackFunction watcher = null;
|
||||
watcher = () =>
|
||||
{
|
||||
if (surface == null || surface.BakeJob == null)
|
||||
if (surface == null)
|
||||
{
|
||||
EditorApplication.update -= watcher;
|
||||
return;
|
||||
}
|
||||
if (surface.BakeJob.IsFinished)
|
||||
|
||||
var bakeJob = s_bakeJobProp?.GetValue(surface);
|
||||
if (bakeJob == null)
|
||||
{
|
||||
EditorApplication.update -= watcher;
|
||||
return;
|
||||
}
|
||||
|
||||
bool isFinished = (bool)bakeJob.GetType()
|
||||
.GetProperty("IsFinished")!.GetValue(bakeJob);
|
||||
if (isFinished)
|
||||
{
|
||||
EditorApplication.update -= watcher;
|
||||
EditorUtility.SetDirty(surface);
|
||||
Debug.Log($"[NavSurfaceBake] ✓ {surface.name} 烘焙完成({surface.BakeJob.TotalBakeTime} ms)");
|
||||
float totalTime = (float)bakeJob.GetType()
|
||||
.GetProperty("TotalBakeTime")!.GetValue(bakeJob);
|
||||
Debug.Log($"[NavSurfaceBake] ✓ {surface.name} 烘焙完成({totalTime} ms)");
|
||||
}
|
||||
};
|
||||
return watcher;
|
||||
|
||||
@@ -10,6 +10,7 @@ using BaseGames.Enemies;
|
||||
using BaseGames.Input;
|
||||
using BaseGames.Player;
|
||||
using BaseGames.Player.States;
|
||||
using BaseGames.Skills;
|
||||
using BaseGames.UI;
|
||||
using BaseGames.UI.HUD;
|
||||
using BaseGames.UI.Menus;
|
||||
|
||||
Reference in New Issue
Block a user