From 43a8643425519a0e5d5dd5ea305541921d217b4b Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sat, 16 Nov 2024 23:41:35 +0900 Subject: [PATCH 1/2] fix: NRE on save prefab from PrefabStage --- .../PrefabSafeUniqueCollectionRuntimeEditorImpl.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Internal/PrefabSafeSet/Editor/UniqueCollection/PrefabSafeUniqueCollectionRuntimeEditorImpl.cs b/Internal/PrefabSafeSet/Editor/UniqueCollection/PrefabSafeUniqueCollectionRuntimeEditorImpl.cs index 851ab43ef..e9c6d6caa 100644 --- a/Internal/PrefabSafeSet/Editor/UniqueCollection/PrefabSafeUniqueCollectionRuntimeEditorImpl.cs +++ b/Internal/PrefabSafeSet/Editor/UniqueCollection/PrefabSafeUniqueCollectionRuntimeEditorImpl.cs @@ -32,6 +32,9 @@ public static void OnValidate(TComponent component, // - OnValidate will be called for prefab instance when the base prefab is changed var PrefabSafeUniqueCollection = getPrefabSafeUniqueCollection(component); + // The prefab from prefab stage is going to be saved. I don't update on this phase. + if (component == null) return; + // detect creating new prefab var newCorrespondingObject = PrefabUtility.GetCorrespondingObjectFromSource(component); if (newCorrespondingObject != null && From 1d96f8d2cd7258f004f0dd4b0db8dad5f4dd9aa5 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 17 Nov 2024 14:14:18 +0900 Subject: [PATCH 2/2] docs(changelog): NRE when saving Prefab with PrefabSafeUniqueCollection --- CHANGELOG-PRERELEASE.md | 1 + CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index 1bde3d225..33ba7c497 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog]. ### Removed ### Fixed +- NRE when saving Prefab with PrefabSafeUniqueCollection `#1348` ### Security diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cd82bcec..f459d7fec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,7 +82,7 @@ The format is based on [Keep a Changelog]. - Reimplement Preview system with NDMF Preview System `#1131` `#1195` `#1218` `#1270` - This will prevent issues relates to Animation Mode bug. - This allows you to preview Remove Mesh components without selecting Mesh OR while in Animation Mode. -- Improved Prefab Safe Set, which are used in MergePhysBone, MergeSkinnedMesh, FreezeBlendShape and more components `#1212` `#1219` `#1221` `#1236` `#1287` `#1294` +- Improved Prefab Safe Set, which are used in MergePhysBone, MergeSkinnedMesh, FreezeBlendShape and more components `#1212` `#1219` `#1221` `#1236` `#1287` `#1294` `#1348` - This should improve compatibility with replacing base prefab, which is added in Unity 2022. - Allow multiple component for Remove Mesh components with API `#1216` `#1218` - This allows non-destructive tools to add Remove Mesh components even if Remove Mesh component are added before.