diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index a98d65f4c..b913216ce 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog]. ### Removed ### Fixed +- None is added/removed on the prefab modifications `#73` ### Security diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd645dd6..d9d1e5677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog]. ### Fixed - save version is not saved again `#69` +- None is added/removed on the prefab modifications `#73` ### Security diff --git a/Internal/PrefabSafeSet/Editor/EditorUtil.PrefabModification.cs b/Internal/PrefabSafeSet/Editor/EditorUtil.PrefabModification.cs index b97a7825b..ee7a61c13 100644 --- a/Internal/PrefabSafeSet/Editor/EditorUtil.PrefabModification.cs +++ b/Internal/PrefabSafeSet/Editor/EditorUtil.PrefabModification.cs @@ -122,6 +122,7 @@ private void DoInitializeUpstream() foreach (var prop in new ArrayPropertyEnumerable(additions)) { var value = _getValue(prop); + if (value == null) continue; if (upstreamValues.Add(value)) _elements.Add(ElementImpl.Natural(this, value, i + 1)); } @@ -235,6 +236,7 @@ public void DoInitialize() for (var i = 0; i < additionsArray.Length; i++) { var value = additionsArray[i]; + if (value == null) continue; if (!addsSet.Contains(value)) continue; // it's duplicated addition _elements.Add(ElementImpl.NewElement(this, value, i)); @@ -244,6 +246,7 @@ public void DoInitialize() for (var i = 0; i < removesArray.Length; i++) { var value = removesArray[i]; + if (value == null) continue; if (!removesSet.Contains(value)) continue; // it's removed upper layer _elements.Add(ElementImpl.FakeRemoved(this, value, i)); @@ -262,7 +265,11 @@ public override void Clear() _currentAdditionsSize = _currentAdditions.arraySize = 0; } - protected override IElement NewSlotElement(T value) => ElementImpl.NewSlot(this, value); + protected override IElement NewSlotElement([NotNull] T value) + { + if (value == null) throw new ArgumentNullException(nameof(value)); + return ElementImpl.NewSlot(this, value); + } private class ElementImpl : IElement { @@ -298,6 +305,7 @@ public bool Contains private ElementImpl(PrefabModification container, int indexInModifier, T value, ElementStatus status, int sourceNestCount, SerializedProperty modifierProp) { + if (value == null) throw new ArgumentNullException(nameof(value)); _container = container; _indexInModifier = indexInModifier; SourceNestCount = sourceNestCount;