From fc28310e613e11d3f527427fcddbec4516b66b0b Mon Sep 17 00:00:00 2001 From: bd_ Date: Tue, 2 Jul 2024 12:10:10 +0900 Subject: [PATCH] fix: minor bugs in preview system (#281) --- Editor/ChangeStream/ListenerSet.cs | 9 ++++++++- Editor/ChangeStream/ObjectWatcher.cs | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Editor/ChangeStream/ListenerSet.cs b/Editor/ChangeStream/ListenerSet.cs index 1479f07b..ce3d272b 100644 --- a/Editor/ChangeStream/ListenerSet.cs +++ b/Editor/ChangeStream/ListenerSet.cs @@ -54,10 +54,17 @@ internal void MaybeFire(T info) else if (_filter(info)) { ctx.Invalidate(); - EditorApplication.delayCall += SceneView.RepaintAll; + // We need to wait two frames before repainting: One to process task callbacks, then one to actually + // repaint (and update previews). + EditorApplication.delayCall += Delay2Repaint; Dispose(); } } + + private void Delay2Repaint() + { + EditorApplication.delayCall += SceneView.RepaintAll; + } } internal class ListenerSet diff --git a/Editor/ChangeStream/ObjectWatcher.cs b/Editor/ChangeStream/ObjectWatcher.cs index 213d5122..03712b20 100644 --- a/Editor/ChangeStream/ObjectWatcher.cs +++ b/Editor/ChangeStream/ObjectWatcher.cs @@ -186,6 +186,8 @@ public R MonitorObjectProps(T obj, ComputeContext ctx, Func extract, if (usePropMonitor) { + if (obj is Component c && c.gameObject.hideFlags != 0) return curVal; + var propsListeners = PropertyMonitor.MonitorObjectProps(obj); propsListeners.Register(_ => obj == null || !compare(curVal, extract(obj)), ctx);