Skip to content

Commit

Permalink
Merge pull request #1287 from anatawa12/invaild-operation-exception-i…
Browse files Browse the repository at this point in the history
…n-psuc

fix: InvalidOperationException in PSUCRuntimeUtil
  • Loading branch information
anatawa12 authored Oct 20, 2024
2 parents 63f4d9b + db1fce3 commit 8b057b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog].

### Fixed
- Error with material property animation `#1285`
- InvalidOperationException in PrefabSafeUniqueCollection `#1287`

### Security

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,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`
- Improved Prefab Safe Set, which are used in MergePhysBone, MergeSkinnedMesh, FreezeBlendShape and more components `#1212` `#1219` `#1221` `#1236` `#1287`
- 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.
Expand Down
7 changes: 6 additions & 1 deletion Internal/PrefabSafeSet/Runtime/PrefabSafeUniqueCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ public static bool ShouldUsePrefabOnSceneLayer(Object instance)
if (currentPrefabStage != null)
{
var instanceGameObject = instance as GameObject ?? (instance as Component)?.gameObject;
isAsset |= currentPrefabStage.IsPartOfPrefabContents(instanceGameObject);
// isAsset |= currentPrefabStage.IsPartOfPrefabContents(instanceGameObject);
// but ^^ will cause InvalidOperationException.
// This is because `OnValidate` invocation is from `PrefabStageUtility:LoadPrefabIntoPreviewScene`
// invocation in PrefabStage.LoadStage method, which assigns m_PrefabContentsRoot.
// scene property is already available so we use it instead for detecting GameObjects in the PrefabStage.
isAsset |= instanceGameObject?.scene == currentPrefabStage.scene;
}

return isInstance && !isAsset;
Expand Down

0 comments on commit 8b057b5

Please sign in to comment.