From c294ac25a08c123abc0c320f3baa2a4e3d724e04 Mon Sep 17 00:00:00 2001 From: bd_ Date: Wed, 21 Aug 2024 20:32:46 -0700 Subject: [PATCH] fix: NRE from SetupRenderingMonitoring on scene change Reported-In: #345 --- CHANGELOG.md | 2 +- Editor/PreviewSystem/Rendering/ProxyObjectController.cs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b73ae3a..b63e629 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Fixed - - [#343] [#346] TargetSet is not invalidated when GetTargetGroups context is invalidated +- [#347] NullReferenceException from SetupRenderingMonitoring on scene change ### Changed diff --git a/Editor/PreviewSystem/Rendering/ProxyObjectController.cs b/Editor/PreviewSystem/Rendering/ProxyObjectController.cs index 775c0f8..5e85daa 100644 --- a/Editor/PreviewSystem/Rendering/ProxyObjectController.cs +++ b/Editor/PreviewSystem/Rendering/ProxyObjectController.cs @@ -80,6 +80,12 @@ public ProxyObjectController(ProxyObjectCache cache, Renderer originalRenderer, private void SetupRendererMonitoring(Renderer r) { + if (r == null) + { + OnInvalidate = Task.CompletedTask; + return; + } + var gameObjectName = r.gameObject.name; _monitorRenderer = new ComputeContext("Renderer Monitor for " + gameObjectName); _monitorMaterials = new ComputeContext("Material Monitor for " + gameObjectName);