From 65dc1eb1eb3c75719da2b6dee414a8f6c107b27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vauchelles?= Date: Thu, 2 Jul 2020 15:59:22 +0200 Subject: [PATCH] Fixed an error when switch area light shape to disk while an emissive mesh is displayed. --- .../CHANGELOG.md | 1 + .../Editor/Lighting/SerializedHDLight.cs | 12 ++++++++---- .../Editor/RenderPipeline/HDEditorUtils.cs | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 7189925eb13..8f89aed8d26 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -709,6 +709,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed fallback for ray tracing and light layers (1258837). - Fixed Sorting Priority not displayed correctly in the DrawRenderers custom pass UI. - Fixed glitch in Project settings window when selecting diffusion profiles in material section (case 1253090) +- Fixed errors when switching area light to disk shape while an area emissive mesh was displayed. ### Changed - Improve MIP selection for decals on Transparents diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs index de2021cc109..df0c9052e32 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs @@ -472,8 +472,10 @@ public void Update() settings.Update(); lightGameObject.Update(); - deportedAreaLightEmissiveMeshMotionVector?.serializedObject.Update(); - deportedAreaLightEmissiveMeshLayer?.serializedObject.Update(); + if (deportedAreaLightEmissiveMeshMotionVector.IsTargetAlive()) + deportedAreaLightEmissiveMeshMotionVector?.serializedObject.Update(); + if (deportedAreaLightEmissiveMeshLayer.IsTargetAlive()) + deportedAreaLightEmissiveMeshLayer?.serializedObject.Update(); } void ApplyInternal(bool withDeportedEmissiveMeshData) @@ -482,8 +484,10 @@ void ApplyInternal(bool withDeportedEmissiveMeshData) settings.ApplyModifiedProperties(); if (withDeportedEmissiveMeshData) { - deportedAreaLightEmissiveMeshMotionVector?.serializedObject.ApplyModifiedProperties(); - deportedAreaLightEmissiveMeshLayer?.serializedObject.ApplyModifiedProperties(); + if (deportedAreaLightEmissiveMeshMotionVector.IsTargetAlive()) + deportedAreaLightEmissiveMeshMotionVector?.serializedObject.ApplyModifiedProperties(); + if (deportedAreaLightEmissiveMeshLayer.IsTargetAlive()) + deportedAreaLightEmissiveMeshLayer?.serializedObject.ApplyModifiedProperties(); } } diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs index 29c7745ea9b..1ef64600f1f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs @@ -287,6 +287,10 @@ public static IEnumerable EnumerateDisplayName(this SerializedProperty p yield return property.displayName; } + public static bool IsTargetAlive(this SerializedProperty property) + => property != null && property.serializedObject.targetObject != null && + !property.serializedObject.targetObject.Equals(null); + /// /// Helper to get an enum value from a SerializedProperty. /// This handle case where index do not correspond to enum value.