diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index 1bde3d22..33ba7c49 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 3cd82bce..f459d7fe 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. diff --git a/Internal/PrefabSafeSet/Editor/UniqueCollection/PrefabSafeUniqueCollectionRuntimeEditorImpl.cs b/Internal/PrefabSafeSet/Editor/UniqueCollection/PrefabSafeUniqueCollectionRuntimeEditorImpl.cs index 851ab43e..e9c6d6ca 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 &&