From 1bce1b3e762225f1119227bb6bf5cf889473a7f0 Mon Sep 17 00:00:00 2001 From: Rerigferl <70315656+AshleyScarlet@users.noreply.github.com> Date: Sun, 6 Oct 2024 10:41:35 +0900 Subject: [PATCH] fix: Picking status is not synchronized --- .../Rendering/ProxyObjectController.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Editor/PreviewSystem/Rendering/ProxyObjectController.cs b/Editor/PreviewSystem/Rendering/ProxyObjectController.cs index a86db9d..ff7b183 100644 --- a/Editor/PreviewSystem/Rendering/ProxyObjectController.cs +++ b/Editor/PreviewSystem/Rendering/ProxyObjectController.cs @@ -152,24 +152,25 @@ internal bool OnPreFrame() { _pickingOffOriginal = SceneVisibilityManager.instance.IsPickingDisabled(original.gameObject); _visibilityOffOriginal = SceneVisibilityManager.instance.IsHidden(original.gameObject); - } - - target.enabled = false; - - bool shouldDisablePicking = _pickingOffOriginal || _visibilityOffOriginal; - if (shouldDisablePicking != _pickingOffReplacement) - { - if (shouldDisablePicking) - { - SceneVisibilityManager.instance.DisablePicking(target.gameObject, false); - } - else + var pickingOffTarget = SceneVisibilityManager.instance.IsPickingDisabled(target.gameObject); + if (_pickingOffOriginal != pickingOffTarget) { - SceneVisibilityManager.instance.EnablePicking(target.gameObject, false); + if (_pickingOffOriginal) + { + SceneVisibilityManager.instance.DisablePicking(target.gameObject, false); + } + else + { + SceneVisibilityManager.instance.EnablePicking(target.gameObject, false); + } } + + _lastVisibilityCheck = VisibilityMonitor.Sequence; } + target.enabled = false; + SkinnedMeshRenderer smr = null; if (_originalRenderer is SkinnedMeshRenderer smr_) {