feat: hybrid NetcodeConfig defaults - #4144
Conversation
When Netcode for Entities is installed and a registered network prefab carries a GhostObject, the project's NetCodeConfig is now aligned with what NGO needs rather than leaving it to the user to discover. The two settings hybrid mode cannot run without (single world hosting, and automatic bootstrapping disabled since NetworkManager owns world creation) are corrected whenever they drift. The Netcode for Entities tick rates are driven from NetworkConfig.TickRate so that ghost transform updates land on the same interval as everything else. The snapshot, interpolation and transport values tuned against the 2000 instance stress test are applied once and then left alone, so a user's own edits survive; Project Settings > Multiplayer > Netcode for GameObjects can restore them. The config is never created here. Netcode for Entities already creates one unconditionally from its own InitializeOnLoadMethod, and creating a second lands the project in its multiple-config error path. Also: - UnifiedIsConfiguredCorrectly now validates EnableClientServerBootstrap and warns when the two tick rates diverge. Its two log messages were missing their string interpolation prefixes. - m_TempStreamSize returns to the Netcode for Entities default of 8192. GhostSendSystem takes max(TempStreamInitialSize, dataStream.Capacity), and capacity is DefaultSnapshotPacketSize, so 4192 had no effect. - Unity.Netcode.Editor.Tests gains the UNIFIED_NETCODE version define. Without it any hybrid editor test compiles away and reports zero cases rather than failing. - Adds a measurement fixture for sizing DefaultSnapshotPacketSize. It is marked Explicit so its 24 cases stay out of the suites.
There was a problem hiding this comment.
💡 Harness Review
The new hybrid configuration flow establishes the intended defaults and exposes them in settings, but several reachable editor states prevent it from preserving or aligning those defaults correctly.
Reviewed commit 49e605e
🤖 Helpful? 👍/👎
| /// </summary> | ||
| internal static bool IsHybridProject() | ||
| { | ||
| foreach (var networkManager in Resources.FindObjectsOfTypeAll<NetworkManager>()) |
There was a problem hiding this comment.
FindObjectsOfTypeAll only sees loaded objects; it does not enumerate NetworkManagers in unopened scene or prefab assets. Thus, if a project has its manager-with-ghost-registration in a closed scene at domain reload, this returns false and no defaults are applied. Opening that scene later does not invoke this initialization hook, and the postprocessor only reacts to imports of ghost GameObjects, so entering Play Mode can still fail the required hybrid configuration validation. Discover persisted manager assets (or trigger a rescan when their registration changes/when scenes open) rather than relying solely on currently loaded managers.
🤖 Helpful? 👍/👎
Fixing some things u-pr caught and adding a test to validate the update.
|
Is it possible to add a call to action to the console log that the user can click on the directly open the relevant page? |
I was actually thinking that we should make that a dialog box that explains what was updated and where to reset back to the defaults. The console log could easily be missed.
This would be a change to the NetcodeConfig property drawer in N4E. |
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## develop-3.x.x #4144 +/- ##
=================================================
+ Coverage 78.01% 78.08% +0.06%
=================================================
Files 153 153
Lines 26260 26273 +13
=================================================
+ Hits 20486 20514 +28
+ Misses 5774 5759 -15
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes
|
Ah ok ok! Yea, a helpbox with some Call-to-action would make more sense.
Yea, we could look at the workflow a bit closer |
EmandM
left a comment
There was a problem hiding this comment.
Big concern here with using AssetDatabase.FindAssets.
- It's very slow
- The pattern will change and/or go away as the editor moves towards importing on demand.
Relevant assets should register themselves in OnEnable, that way behaviour will be automatically triggered when relevant rather than doing an expensive search over many irrelevant things.
| /// snapshot metrics singleton for a fixed sample window. Results are emitted as "PKTSZ|" log lines. | ||
| /// </summary> | ||
| [TestFixture(HostOrServer.UnifiedHost)] | ||
| [Explicit("Measurement harness, not a regression test. The 24 auto-expanded cases take ~162s, so it only runs when selected by name: -testFilter \".*UnifiedSnapshotPacketSizeMeasurement.*\"")] |
There was a problem hiding this comment.
Can we not add tests that we have to explictly run. We're going to forget they exist and never run them
There was a problem hiding this comment.
The explicit attribute:
Measurement harness, not a regression test.
It is just a tool for measurement purposes. If you would like me to remove this tool I can do that.
(I can keep a copy of this somewhere else so I can run this to verify the snapshot sizes)
There was a problem hiding this comment.
What is it measuring? When do we need to be measuring? Might be worth writing some internal docs explaining that the tool exists and what it does?
Pull request was converted to draft
There was a problem hiding this comment.
💡 Harness Review
The one-shot defaults flow and runtime tick alignment are coherent for hybrid sessions, but the editor initialization also changes the shared Netcode for Entities configuration in projects that never use hybrid prefabs.
Reviewed commit f12c046
🤖 Helpful? 👍/👎
None of this script exists anymore. |
Purpose of this PR
This PR introduces an automated NetcodeConfig default settings feature where NGO will, at a minimum, configure NGO user's NetcodeConfig settings to the recommended settings.
The UI
The only UI added in this PR pertains to Project Settings--> Multiplayer--> Netcode for GameObjects.

Users can reset their selected NetcodeConfig (defined by N4E's setting under Multiplayer) back to the recommended NGO settings.
Jira ticket
MTT-15571
Changelog
NetworkConfig.TickRatewhen a session with Hybrid prefabs is started to align snapshot updates on the same (relative) interval as the rest of Netcode for GameObjects. (feat: hybrid NetcodeConfig defaults #4144)Documentation
Testing & QA (How your changes can be verified during release Playtest)
Functional Testing
Manual testing :
Manual testing doneYou can also look at the NetcodeConfig.asset file and spot check:
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?If any boxes above are checked the QA team will be automatically added as a PR reviewer.
Up-port
None
Backports
None