Repository navigation
fix: remove the NetworkObjectBridge when a hybrid prefab stops being hybrid - #4211
NoelStephensUnity wants to merge 6 commits into
Conversation
…hybrid Removing GhostObject from a hybrid prefab now removes only the hidden NetworkObjectBridge and any GhostRigidbody, instead of every GhostBehaviour, and restores SynchronizeTransform. Removing NetworkObject from a hybrid prefab also removes the bridge. The bridge now sets FullTickSmoothing in place of the obsolete SingleWorldHostInterpolationSmoothing.
|
@u-pr please review again |
|
Here is a summary of findings from reviewing the updated changes: 1.
|
| if (this != null) | ||
| { | ||
| DestroyImmediate(this, true); | ||
| } |
There was a problem hiding this comment.
Fun fact (I just tested this), DestroyImmediate will handle the null internally so we can simplify this even further!
| if (this != null) | |
| { | |
| DestroyImmediate(this, true); | |
| } | |
| DestroyImmediate(this, true); |
There was a problem hiding this comment.
Applied, thanks.
…allbacks The GhostObject removal hook now re-runs UnifiedValidation on the next editor tick, so GhostObject and HasGhost match the components on the prefab stage root, and the bridge comes back when the hook fired for a different GhostBehaviour. The deferred add/remove callbacks unsubscribe first and return when their NetworkObject was destroyed.
| { | ||
| if (networkObject) | ||
| { | ||
| networkObject.UnifiedValidation(); |
There was a problem hiding this comment.
Removing a user GhostBehaviour from a predicted hybrid prefab resets SupportedGhostModes to Interpolated. OnGhostObjectPreRemoval also fires for other GhostBehaviour components, as the new comment notes. OnRemoveNetworkObjectBridge destroys the existing bridge even when GhostObject remains. The delayed UnifiedValidation then schedules a replacement bridge. NetworkObjectBridge.Reset explicitly sets SupportedGhostModes to Interpolated, overwriting the user's prediction setting. Preserve and restore SupportedGhostModes when rebuilding the bridge after an unrelated component removal.
🤖 Helpful? 👍/👎
…modes UnifiedValidation removes a leftover NetworkObjectBridge, so the GhostObjectEditor pre-removal callback is no longer needed. It also fired when the inspection component was removed, and the rebuilt bridge reset SupportedGhostModes. The bridge no longer forces SupportedGhostModes to Interpolated.
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## develop-3.x.x #4211 +/- ##
=================================================
- Coverage 76.03% 75.92% -0.11%
=================================================
Files 159 159
Lines 27344 27382 +38
=================================================
Hits 20791 20791
- Misses 6553 6591 +38
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Purpose of this PR
Removing
GhostObjectorNetworkObjectfrom a hybrid prefab now leaves a clean prefab, without the hiddenNetworkObjectBridgeleft behind.Removing
GhostObject: the pre-removal callback now removes only theNetworkObjectBridgeand anyGhostRigidbody, andSynchronizeTransformis enabled again. Previously it destroyed everyGhostBehaviouron the prefab, including user scripts.Removing
NetworkObject: theNetworkObjectBridgenow removes itself when itsNetworkObjectis gone.In-scene placed hybrid instances: the
GhostObjectis now removed through the same path, so the bridge is removed with it.The bridge also now sets
FullTickSmoothingin place of the obsoleteSingleWorldHostInterpolationSmoothing.PR Scope:
NetworkObject,NetworkObjectEditorandNetworkObjectBridge.Out of scope:
GhostBehaviours whenGhostObjectis removed (they belong to the user).GhostRigidbody/ replicate-rigidbody settings whenGhostObjectis removed (N4E owns those).Jira ticket
N/A
Changelog
None (hybrid prefabs require an unreleased N4E version).
Documentation
Testing & QA (How your changes can be verified during release Playtest)
Functional Testing
Manual testing :
Manual testing done: add and removeGhostObjectandNetworkObjecton a hybrid prefab in the inspector, and toggle the Networked checkbox.Automated tests:
Covered by existing automated testsCovered by new automated testsDoes the change require QA team to:
Review automated tests?Execute manual tests?Provide feedback about the PR?Up-port
Not needed: hybrid prefabs are NGO 3.x only.
Backports
Not needed: hybrid prefabs are NGO 3.x only.