Skip to content

fix: set the in scene placed field prior to serializing#4086

Open
NoelStephensUnity wants to merge 19 commits into
develop-2.0.0from
fix/set-in-scene-when-serializing
Open

fix: set the in scene placed field prior to serializing#4086
NoelStephensUnity wants to merge 19 commits into
develop-2.0.0from
fix/set-in-scene-when-serializing

Conversation

@NoelStephensUnity

Copy link
Copy Markdown
Member

Purpose of this PR

This fixes an edge case scenario where non-spawned NetworkObjects migrated into the DDOL during awake would not get spawned upon starting a session as a server, host, or session owner.

Jira ticket

Extension for #4073

Changelog

  • Changed: NetworkObject now implements ISerializationCallbackReceiver in order to assure NetworkObject.InScenePlaced is set and serialized for any in-editor in-scene placed NetworkObject.

Documentation

  • No documentation changes or additions were necessary.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests
    • Added NetworkSceneManagerStartupTests and associated assets to testproject.

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

If any boxes above are checked the QA team will be automatically added as a PR reviewer.

Backports

Does not require a backport.

EmandM and others added 11 commits July 10, 2026 19:30
- Adjusted the `InScenePlaced` property to internally set or publicly get the serialized `m_InScenePlaced` field.
- `NetworkObject` now implements `ISerializationCallbackReceiver` to assure `m_InScenePlaced` is always properly set for in-scene placed objects.
- Removed legacy define for UNITY_2021_2_OR_NEWER since v2.x.x+ is only for Unity v6.
- Adding `NetworkSceneManagerStartupTests` which validates this PR.
- Adding the assets and script needed to validate this PR.
- Updated scenes in build list to include the new scene: InSceneNetworkObjectMovesToDDOL.
Adding change log entry.
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review July 14, 2026 17:03
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner July 14, 2026 17:03
@codecov-github-com

codecov-github-com Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 44.00000% with 56 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
....netcode.gameobjects/Runtime/Core/NetworkObject.cs 35.13% 24 Missing ⚠️
...gameobjects/Runtime/Configuration/NetworkPrefab.cs 14.28% 12 Missing ⚠️
...tcode.gameobjects/Editor/InScenePlacedProcessor.cs 20.00% 8 Missing ⚠️
...ameobjects/Runtime/Spawning/NetworkSpawnManager.cs 50.00% 8 Missing ⚠️
....netcode.gameobjects/Runtime/Logging/NetworkLog.cs 82.60% 4 Missing ⚠️
@@                Coverage Diff                @@
##           develop-2.0.0    #4086      +/-   ##
=================================================
+ Coverage          66.33%   66.44%   +0.11%     
=================================================
  Files                163      163              
  Lines              24927    24972      +45     
=================================================
+ Hits               16535    16593      +58     
+ Misses              8392     8379      -13     
Flag Coverage Δ
NGOv2_ubuntu_6000.3 66.44% <44.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
....netcode.gameobjects/Runtime/Logging/NetworkLog.cs 73.01% <82.60%> (+19.01%) ⬆️
...tcode.gameobjects/Editor/InScenePlacedProcessor.cs 54.16% <20.00%> (-24.41%) ⬇️
...ameobjects/Runtime/Spawning/NetworkSpawnManager.cs 66.44% <50.00%> (+0.29%) ⬆️
...gameobjects/Runtime/Configuration/NetworkPrefab.cs 66.35% <14.28%> (-7.84%) ⬇️
....netcode.gameobjects/Runtime/Core/NetworkObject.cs 63.94% <35.13%> (-0.17%) ⬇️

... and 5 files with indirect coverage changes

Components Coverage Δ
com.unity.netcode.gameobjects 66.44% <44.00%> (+0.11%) ⬆️

ℹ️ Need help interpreting these results?

EmandM and others added 8 commits July 14, 2026 14:21
Fixing issue with marking things as in-scene placed during runtime.
Commenting out the addressable scene test.
Adding back the check for InScenePlaced when shutting down.
- `ISerializationCallbackReceiver` implementation as that does not accomplish what we need.
- Setting InScenePlaced within OnValidate instead.
Only reset things that have been spawned are in-scene placed, and is assigned to the relative NetworkManager (for integration testing purposes)
Removing the addressable scene.
We will revisit this when this is supported.
Fixing several issues with NetworkObjectSceneMigrationTests.
Fixing several formatting issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants