diff --git a/Assets/_Game/Scripts/Editor/Enemies/PhysicsPerceptionSystemEditor.cs b/Assets/_Game/Scripts/Editor/Enemies/PhysicsPerceptionSystemEditor.cs index f92fad8f..c13bf005 100644 --- a/Assets/_Game/Scripts/Editor/Enemies/PhysicsPerceptionSystemEditor.cs +++ b/Assets/_Game/Scripts/Editor/Enemies/PhysicsPerceptionSystemEditor.cs @@ -15,10 +15,28 @@ namespace BaseGames.Editor private SerializedProperty _slotsProp; private readonly List _foldouts = new List(); + // 运行时检测结果刷新限频:定频请求重绘(~5Hz),与游戏帧率解耦。 + // 否则 OnInspectorGUI 尾部每帧 Repaint 会强制整个多组件 Inspector 以游戏帧率(100+fps) + // 重绘 IMGUI(本编辑器逐槽位属性 + 同物体其它自定义编辑器),选中敌人即掉帧。 + private const double RepaintInterval = 0.2; + private double _nextRepaintTime; + private void OnEnable() { _slotsProp = serializedObject.FindProperty("_slots"); SyncFoldouts(); + EditorApplication.update += ThrottledRepaint; + } + + private void OnDisable() => EditorApplication.update -= ThrottledRepaint; + + private void ThrottledRepaint() + { + if (!Application.isPlaying || target == null) return; + double t = EditorApplication.timeSinceStartup; + if (t < _nextRepaintTime) return; + _nextRepaintTime = t + RepaintInterval; + Repaint(); } private void SyncFoldouts() @@ -477,7 +495,7 @@ namespace BaseGames.Editor } EditorGUILayout.LabelField(kvp.Key, kvp.Value.Count > 0 ? sb.ToString() : "—"); } - Repaint(); + // 重绘由 ThrottledRepaint 定频驱动,这里不再每帧 Repaint(否则强制整个 Inspector 满帧重绘)。 } ///