From 9494c080bd1a98ee9394eb11465c1298f931636b Mon Sep 17 00:00:00 2001 From: martint-unity Date: Wed, 16 Sep 2020 14:30:06 +0200 Subject: [PATCH 1/2] fix case 1244430 camera prefab null ref cam comp --- .../UniversalRenderPipelineCameraEditor.cs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineCameraEditor.cs b/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineCameraEditor.cs index a3242383c37..ac2c302846b 100644 --- a/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineCameraEditor.cs +++ b/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineCameraEditor.cs @@ -940,13 +940,28 @@ public void RemoveComponent(Camera camera, IEnumerable dependencies) return; } - Undo.SetCurrentGroupName("Remove Universal Camera"); - var additionalCameraData = camera.GetComponent(); - if (additionalCameraData) + var isAssetEditing = EditorUtility.IsPersistent(camera); + try { - Undo.DestroyObjectImmediate(additionalCameraData); + if (isAssetEditing) + { + AssetDatabase.StartAssetEditing(); + } + Undo.SetCurrentGroupName("Remove Universal Camera"); + var additionalCameraData = camera.GetComponent(); + if (additionalCameraData != null) + { + Undo.DestroyObjectImmediate(additionalCameraData); + } + Undo.DestroyObjectImmediate(camera); + } + finally + { + if (isAssetEditing) + { + AssetDatabase.StopAssetEditing(); + } } - Undo.DestroyObjectImmediate(camera); } } } From 6f7cb735faeb72958296ef9c015d4b38434fccb1 Mon Sep 17 00:00:00 2001 From: martint-unity Date: Wed, 16 Sep 2020 14:53:02 +0200 Subject: [PATCH 2/2] updated change log --- com.unity.render-pipelines.universal/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index 5aae5a4f82f..c6dbeb7de1d 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed not using the local skybox on the camera game object when the Skybox Material property in the Lighting window was set to null. - Fixed an issue where, if URP was not in use, you would sometimes get errors about 2D Lights when going through the menus. - Fixed GC when using XR single-pass automated tests. +- Fixed an issue that caused a null reference when deleting camera component in a prefab. [case 1244430](https://issuetracker.unity3d.com/issues/urp-argumentnullexception-error-is-thrown-on-removing-camera-component-from-camera-prefab) ## [10.0.0] - 2019-06-10 ### Added