Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: none is added/removed on the prefab modifications #73

Merged
merged 2 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- None is added/removed on the prefab modifications `#73`

### Security

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion Internal/PrefabSafeSet/Editor/EditorUtil.PrefabModification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -262,7 +265,11 @@ public override void Clear()
_currentAdditionsSize = _currentAdditions.arraySize = 0;
}

protected override IElement<T> NewSlotElement(T value) => ElementImpl.NewSlot(this, value);
protected override IElement<T> NewSlotElement([NotNull] T value)
{
if (value == null) throw new ArgumentNullException(nameof(value));
return ElementImpl.NewSlot(this, value);
}

private class ElementImpl : IElement<T>
{
Expand Down Expand Up @@ -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;
Expand Down