Skip to content

feat: hybrid NetcodeConfig defaults - #4144

Open
NoelStephensUnity wants to merge 14 commits into
develop-3.x.xfrom
feat/hybrid-netcodeconfig-defaults
Open

feat: hybrid NetcodeConfig defaults#4144
NoelStephensUnity wants to merge 14 commits into
develop-3.x.xfrom
feat/hybrid-netcodeconfig-defaults

Conversation

@NoelStephensUnity

@NoelStephensUnity NoelStephensUnity commented Aug 25, 2026

Copy link
Copy Markdown
Member

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.
image
Users can reset their selected NetcodeConfig (defined by N4E's setting under Multiplayer) back to the recommended NGO settings.

Jira ticket

MTT-15571

Changelog

  • Added: Additional section under Project Settings > Multiplayer > Netcode for GameObjects, shown when Netcode for Entities is installed and provides users a way to restor back to the recommended settings. (feat: hybrid NetcodeConfig defaults #4144)
  • Added: Auto-alignment of the Netcode for Entities tick rate with NetworkConfig.TickRate when 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

  • Includes documentation (wip)

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

Functional Testing

Manual testing :

  • Manual testing done
    • To fully test this you need to:
      • Create a project using an earlier version of 6000.x.x than 6000.7.0a5
        • Add a NetworkManager to the SampleScene.
        • Add these two defines to your project's players defines: (if they still are required)
          • NETCODE_GAMEOBJECT_BRIDGE_EXPERIMENTAL
          • NETCODE_EXPERIMENTAL_SINGLE_WORLD_HOST
          • These are being removed, but currently you still need to add them.
      • If you plan on iterating, make this a local repo to roll back to the default pre-upgrade settings.
    • Open the project using 6000.7.0a5+.
      • Once opened, navigate to the project settings --> Multiplayer --> Netcode for GameObjects.
      • You should see something like the blow picture:
image

You can also look at the NetcodeConfig.asset file and spot check:

  • The snapshot size should have been increased to 15000.
  • Auto bootstrap should be disabled (NGO handles spinning up the worlds).
  • Single world host should be set.

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

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.

Up-port

None

Backports

None

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.
Some comment clean up.
@NoelStephensUnity
NoelStephensUnity requested review from a team and EmandM as code owners August 25, 2026 15:08

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Harness Review

Needs changes

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? 👍/👎

Comment thread com.unity.netcode.gameobjects/Editor/Configuration/HybridNetcodeConfigApplier.cs Outdated
Comment thread com.unity.netcode.gameobjects/Editor/Configuration/HybridNetcodeConfigApplier.cs Outdated
/// </summary>
internal static bool IsHybridProject()
{
foreach (var networkManager in Resources.FindObjectsOfTypeAll<NetworkManager>())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1

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.
@danni-lu

Copy link
Copy Markdown

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?
networkConfigParamter foldout content is a bit too much to the right, can shift 1 level to the left
If I press the apply recommended hybrid defaults button, are settings above it be changed?

@NoelStephensUnity

Copy link
Copy Markdown
Member Author

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? networkConfigParamter foldout content is a bit too much to the right, can shift 1 level to the left If I press the apply recommended hybrid defaults button, are settings above it be changed?

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.

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? networkConfigParamter foldout content is a bit too much to the right, can shift 1 level to the left If I press the apply recommended hybrid defaults button, are settings above it be changed?

This would be a change to the NetcodeConfig property drawer in N4E.
Would you like me to open a ticket for that UI adjustment?

@codecov-github-com

codecov-github-com Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

All 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     
Flag Coverage Δ
NGOv2_project_testproject_ubuntu_pinnedTrunk 77.74% <ø> (?)

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

Files with missing lines Coverage Δ
...netcode.gameobjects/Runtime/Core/NetworkManager.cs 79.78% <ø> (ø)

... and 2 files with indirect coverage changes

Components Coverage Δ
com.unity.netcode.gameobjects 78.08% <95.34%> (+0.06%) ⬆️

ℹ️ Need help interpreting these results?

@danni-lu

Copy link
Copy Markdown

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? networkConfigParamter foldout content is a bit too much to the right, can shift 1 level to the left If I press the apply recommended hybrid defaults button, are settings above it be changed?

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.

Ah ok ok! Yea, a helpbox with some Call-to-action would make more sense.

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? networkConfigParamter foldout content is a bit too much to the right, can shift 1 level to the left If I press the apply recommended hybrid defaults button, are settings above it be changed?

This would be a change to the NetcodeConfig property drawer in N4E. Would you like me to open a ticket for that UI adjustment?

Yea, we could look at the workflow a bit closer

@NoelStephensUnity
NoelStephensUnity enabled auto-merge (squash) August 27, 2026 15:22

@EmandM EmandM left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big concern here with using AssetDatabase.FindAssets.

  1. It's very slow
  2. 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.

Comment thread com.unity.netcode.gameobjects/Editor/Configuration/HybridNetcodeConfigApplier.cs Outdated
Comment thread com.unity.netcode.gameobjects/Editor/Configuration/HybridNetcodeConfigApplier.cs Outdated
Comment thread com.unity.netcode.gameobjects/Editor/Configuration/HybridNetcodeConfigApplier.cs Outdated
Comment thread com.unity.netcode.gameobjects/Editor/Configuration/HybridNetcodeConfigApplier.cs Outdated
Comment thread com.unity.netcode.gameobjects/Editor/Configuration/HybridNetcodeConfigApplier.cs Outdated
Comment thread com.unity.netcode.gameobjects/Editor/Configuration/NetcodeSettingsProvider.cs Outdated
Comment thread com.unity.netcode.gameobjects/Editor/Configuration/NetcodeSettingsProvider.cs Outdated
/// 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.*\"")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not add tests that we have to explictly run. We're going to forget they exist and never run them

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@NoelStephensUnity
NoelStephensUnity marked this pull request as draft August 31, 2026 13:31
auto-merge was automatically disabled August 31, 2026 13:31

Pull request was converted to draft

Refactoring when the NetcodeConfig default settings are written.
Assuring that the NetcodeConfig tick rate is always the currently set tick rate when starting a session.
@NoelStephensUnity
NoelStephensUnity marked this pull request as ready for review August 31, 2026 17:00

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Harness Review

Needs changes

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? 👍/👎

Updating to use a more NGO like testing pattern.
Some comment clean up is included.
@NoelStephensUnity

NoelStephensUnity commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

Big concern here with using AssetDatabase.FindAssets.

  1. It's very slow
  2. 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.

None of this script exists anymore.

resolving concern over the .EndVertical();
removing white space.
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.

4 participants