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 error when editing prefab in 2022 #782

Merged
merged 2 commits into from
Dec 9, 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 @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog].
### Fixed
- Fix NullReferenceException on Unity 2022 when extra Animator components are present [`#778`](https://github.com/anatawq12/AvatarOptimizer/pull/778)
- Fix Errors with Generic Avatars `#779`
- Editing Prefabs with AAO Components in Unity 2022 will cause Error `#782`

### Security

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog].
### Fixed
- Fix NullReferenceException on Unity 2022 when extra Animator components are present [`#778`](https://github.com/anatawq12/AvatarOptimizer/pull/778)
- Fix Errors with Generic Avatars `#779`
- Editing Prefabs with AAO Components in Unity 2022 will cause Error `#782`

### Security

Expand Down
6 changes: 4 additions & 2 deletions Internal/PrefabSafeSet/Runtime/PrefabSafeSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ public static MethodInfo GetOnBeforeSerializeCallbackMethod(Type tType, Type tLa
protected PrefabSafeSet(Object outerObject)
{
#if UNITY_EDITOR
if (!outerObject) throw new ArgumentNullException(nameof(outerObject));
OuterObject = outerObject;
// I don't know why but Unity 2022 reports `this == null` in constructor of MonoBehaviour may be false
// so use actual null check instead of destroy check
// ReSharper disable once Unity.NoNullCoalescing
OuterObject = outerObject ?? throw new ArgumentNullException(nameof(outerObject));
#endif
}

Expand Down