diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index 9f3c8e3b3d4..b8a9fc4e000 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -34,6 +34,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) - Fixed resolution of intermediate textures when rendering to part of a render texture. [case 1261287](https://issuetracker.unity3d.com/product/unity/issues/guid/1261287/) ## [10.0.0] - 2019-06-10 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); } } }