Skip to content

[MTT-14843] Refactor sending and receiving of N4E RPCs in UnifiedNetcodeTransport to not use entities#3943

Merged
ShadauxCat merged 1 commit into
experimental/v3-x-x/unifiedfrom
experimental/v3-x-x/unified-kitty
May 7, 2026
Merged

[MTT-14843] Refactor sending and receiving of N4E RPCs in UnifiedNetcodeTransport to not use entities#3943
ShadauxCat merged 1 commit into
experimental/v3-x-x/unifiedfrom
experimental/v3-x-x/unified-kitty

Conversation

@ShadauxCat
Copy link
Copy Markdown
Collaborator

Purpose of this PR

Refactors sending and receiving of N4E RPCs in the UnifiedNetcodeTransport to not use entities. This removes the need to include a ulong encoding message order and to do message reordering logic on the receiving side.

In addition, I also moved the location where we call NetworkMessageManager.ProcessSendQueue() to be right before N4E processes their send queue. In the place it was previously (PostLateUpdate), N4E wouldn't process anything we sent until the next frame.

Jira ticket

MTT-14843

…reserving send/receive order without having to encode an order value and reorder messages on the receive side.
@ShadauxCat ShadauxCat requested a review from a team as a code owner April 17, 2026 16:41

#if !UNIFIED_NETCODE
// Process outbound messages
MessageManager.ProcessSendQueues();
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.

Hmmm, should we be also checking the transport here? Are we allowing users to still use UnityTransport as normal? Or are you forced into the UnifiedTransport?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Right now, UnifiedTransport is forced when in unified netcode mode. The idea is to update UTP to be able to pass NetworkTransport instance to it that it'll use in the background, so that users can still use their transport instances there.

Copy link
Copy Markdown
Member

@EmandM EmandM left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Copy Markdown
Member

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

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

Looks good Kitty!

@ShadauxCat ShadauxCat merged commit 5cb5cd8 into experimental/v3-x-x/unified May 7, 2026
5 checks passed
@ShadauxCat ShadauxCat deleted the experimental/v3-x-x/unified-kitty branch May 7, 2026 02:52
NoelStephensUnity pushed a commit that referenced this pull request May 18, 2026
* Fix DontDestroyOnLoadTest

* [MTT-14843] Refactor sending and receiving of N4E RPCs in UnifiedNetcodeTransport to not use entities (#3943)

Refactor sending and receiving of RPCs to not use entities, thereby preserving send/receive order without having to encode an order value and reorder messages on the receive side.

* Post-merge fixes

* Fix remaining errors.

* Revert unnecessary change from bad merge.

* Accidentally deleted a line.
NoelStephensUnity added a commit that referenced this pull request Jun 2, 2026
* update

Adjusting namespaces to get NGO running with N4E

* update - wip

This is a "still messy" version that is working but needs more thought on the namespace collision fixes.

* update

Some additions and modifications to finalize the hybrid prefab concept.

* update

cleaning up some of the POC adjustments.
wrapping some debug within loglevel developer.

* update

Getting unified working with the initial synchronization when scene management is enabled.

* update

Providing a temporary way to remove the NetworkObjectBridge.

* update

Adding support within NetworkPrefabs and NetworkPrefab to handle the registration of hybrid spawned objects (i.e. no more hacky-way  of registering).
Moving the hybrid spawn registration into the Start method of the NetworkObject to provide time for everything to run through Awake.
Added some script (defined out) that was helping to debug why NetworkObject was being disabled sometimes (moving the initialization to Start resolved the issue).

* update

NetworkRigidbodyBase and NetworkTransform classes are destroyed during runtime initialization of a prefab instance if they still remain and the instance is a hybrid prefab instance (i.e. unified handles transform synchronization and physics related stuff).

* fix

Fixing issue where there are no NetworkTransforms or NetworkRigidbodyBase derived components.

* fix

Issue with AnimatorOverrideController not being handled which could cause improper processing of the animator's layers and parameters.

Issue with clients sending state changes from the NetworkAnimatorStateChangeHandler due to added HasAuthority check. When using a server authoritative animation model, owner Clients should still be able to send trigger updates to the server.

* update

Migrated the unique world setup into this branch. The world is created prior to starting NetworkManager completely. When using hybrid prefabs (i.e. mixed mode), the final portion of the NetworkManager's start logic (i.e. endpoint connection, etc.) is not invoked until the hybrid prefabs have been registered.
Hybrid prefabs wait until the World is finished starting/being initialized.

* update

Migrating unified things into helpers

* update

Exit early if trying to start in hybrid mode but not configured for a single world.

* update

Added an experimental "NetworkObjectBridge" icon (programmer art alert).
Added some additional script to handle moving the GhostAdapter and NetworkObject bridge to the top of the GameObject's components where GhostAdapter is first and then NetworkObjectBridge is 2nd.

Removed silly code to get the root transform.

* update

Fixing some merge issues.

* update

Making some minor modifications to assure we can make stand alone builds.

* update

Fixing issue where Unity.NetCode was not wrapped by UNIFIED_NETCODE.

* fix

Issue with detecting unified ghost mode.

* update

Automatically handle removing the Rigidbody on non-authority instances when running in client-server mode.

* update - child network behaviours

This update is the first pass to making ChildNetworkBehaviours a table keyed off of the NetworkBehahviour identifiers.
This allows for the removal of a NetworkBehaviour without it impacting the remaining NetworkBehaviours.
This could most likely be optimized by generating the initial table ahead of time on each prefab.
In-scene placed that are not registered prefabs would need to do this upon being instantiated.

* fix

Removing the  update registration when cleaning out NetworkRigidbody.

* fix

Putting back the default world initialization.

* fix

The type of world is now handled by the NGO side UnifiedBootStrap.
Removing the need to use the MPPM stuff.

* fix

Fixing issue with temporary buffer not being copied over properly when synchronizing.

* update

Updating runtimetests to the changes in ChildNetworkBehaviours.

* fix & update

Fixing test project not being able to load without an AnalyticsTests compilation error.
Making ObjectNameIdentifier just use the new way we handle ChildNetworkBehaviours (i.e. it is a table now).
Marking NetworkObject.ChildNetworkBehaviours comment above as having finished the migration to a table.
Noting we should find a better place/way to initialize this stuff.

* update

Adding additional log information only displayed when the log level is Developer.

* update

Possible fix for an edge case scenario during synchronization.

* Transport sharing WIP

* update

preserve hybrid objects pending spawn.

* update

Temporary fix for missed sync.

* update

Delay in-game state for new connections to provide NGO time to start synchronization.

* update

* update

Removing a hack work around that is no longer needed due to recent fixes merged in the dots repo side.

* update

Lowering the in-game connection delay.

* update

Fixing hybrid prefab registration and world initialization order.

* update

Some fixes that should accompany the N4E POC branch.

* - Delay connections from going in game in N4E until initial NGO sync has finished
- Handle messages too large to be sent as a single RPC in N4E (using BatchedSendQueue and BatchedReceiveQueue)
- Handle RPCs being received out of order
- Switched connection flow so that connection is initialized by the transport (typical NGO flow) rather than using AutoConnectPort.

* Got RTT working correctly.

* update

Fixes for connection sequence where clients don't announce they are ready to receive snapshots until fully synchronized by NGO.
Fixes for removing pending ghosts and ghost spawn data (especially when being destroyed).
Fixes for NetworkSceneManager detecting pending ghosts as in-scene placed.
Fixes for NetworkSpawnManager.RegisterGhostPendingSpawn trying to double process triggers and/or process triggers when it should not.

* update & fixes

Some adjustments to the POC Transport.
Some fixes.

* fix

Wrapping reference to namespace that only exists when in unified mode.

* update

fixing spelling of UNIFIED_NETCODE

* update

Increasing max RPC size to 1340.
Re-enabling the UnifiedBootStrap.AutoConnectPort. (N4E handles the connection)
Removing the initial listen and/or connection within the UnifiedTransport (N4E handle this).
Moving unified validation invocation to be after OnValidation early exit checks.

* update

Lowering max packet size to 1300.

* Switched TransportRpc to use the Out-Of-Band RPC pipeline

* update - OUT_OF_BAND_RPC

Wrapping the OutOfBoundRpc stuff until we can get that migrated over.

* update

Adding conditional to determine if we want to use the UnifiedTransport or not.

* chore: merge ngo and n4e with poc transport and updates (#3889)

* update

Fixes for connection sequence where clients don't announce they are ready to receive snapshots until fully synchronized by NGO.
Fixes for removing pending ghosts and ghost spawn data (especially when being destroyed).
Fixes for NetworkSceneManager detecting pending ghosts as in-scene placed.
Fixes for NetworkSpawnManager.RegisterGhostPendingSpawn trying to double process triggers and/or process triggers when it should not.

* update & fixes

Some adjustments to the POC Transport.
Some fixes.

* fix

Wrapping reference to namespace that only exists when in unified mode.

* update

fixing spelling of UNIFIED_NETCODE

* update

Increasing max RPC size to 1340.
Re-enabling the UnifiedBootStrap.AutoConnectPort. (N4E handles the connection)
Removing the initial listen and/or connection within the UnifiedTransport (N4E handle this).
Moving unified validation invocation to be after OnValidation early exit checks.

* update

Lowering max packet size to 1300.

* Optimizations of the UnifiedNetcodeTransport.

* Added support for surfacing disconnect messages

* fix

Fixing a missed namespace, formatting, and some minor style related issues with newly added private statics.

* fix

Delay the sorting of the GhostAdapter and NetworkObjectBridge to avoid from sorting while updating the AssetDatabase.

* Update NetworkObject.cs

* temp-fix

Temporary fix for automatically adding the NetworkObjectBridge and not causing warnings to be logged about sending messages during Awake, OnValidate, etc.

* update

improving how NetworkObjectBridge is added and then sorted to the top with the GhostAdapter.

* update

Adding a base project that can be used to continue development on the unified branch.

* fix

NetworkBehaviour entry fix for the child behaviours being converted to a table.

* Integration tests WIP

* Removed SetActive calls

* update

Some potential fixes (etc) for hybrid spawn integration testing.

* style

removing unused namespace directives.

* update

Adjustments based on earlier discussion.

* update

Resolving merge issues.

* fix:

We need to initialize prefabs prior to checking if we have Ghosts and need to use UnifiedNetcodeTransport.
Fixing the logging and handling for users parenting NetworkManager during runtime.

* update

removing debug log message that causes some tests to fail.

* test-fix

Handling a new scenario where a subSystemList can be null.

* test-fix

Commenting out log message in CreateObjectMessage (leaving it there for potential debug purposes while working on Unified stuff).

* fix

Some left over merge fixes.

* update

Removing legacy component marker from early POC.

* fix

When no player prefab, don't throw an exception (needs a test)

* update - remove NGO-N4E-Example

Removing the example from this specific branch to make reviewing easier.

* update

Removing experimental component helpers (part of the ComponentMarkers stuff that is no longer used).

* update

Adding develop-3.x.x to the triggers.

* update

Reverting test project manifest changes.
Removing the packages-lock.json file (should never be added).

* update

Placing the UnifiedBootstrap into its own file.

* update & style

White space removal.
UnifiedBootstrap name update.

* test

Wrapping the unified test within the UNIFIED_NETCODE define.

* style

Adding CR/LF.

* update - Multiprocess Runtime

Removing this from test project as we have never come back to use it.
(It will still be on the develop-2.0.0 branch)

* fix

Wrapping some unified stuff in defines.

* update

Adding develop-3.x.x to conventional PR branches.

* update

Missed one spot for triggers.

* style - PVP-124-2

Removing trailing whitespaces.

* update: PVP-Exceptions

Adding some exceptions to the v3.x.x branch until we determine if we want to rename those assemblies or have them all in one assembly.

* fix

Fixing typo.

* fix

Fixing json formatting issue.

* fix

Cleaning up the player prefab hash logical flow a bit and making it easier to determine if one was even found.

* style

removing additional whitespace from comment

* update

Updating the package version

* style

indented endregion.

* revert

Reverting changes to manifest for now.

* style

Adding new line.

* style

adding some additional comments.

* update

Updating the project to 6000.3.14f1

* Update

Project version

* update

Making the minimal editor version 6000.3 and removing 6000.0.

* style

Adding comments

* update

Updating triggers to use no less than 6000.3

* Added hybrid spawning to a bunch of existing tests and fixed most of the issues that fell out of that.

* update

Resolving minor issues related to merge.

* style - PVP

Fixing some trailing whitespace issues and PVP missing XML API.

* style

Fixing formatting issues.

* update

Trunk merge updates

* Update & Fix

Some comments and minor adjustments.
Fixing issue where the auto-sort was disabled when using inspector view.

* small merge fixes

* test

Fixing the hybrid spawning test for tests.

* update

Remove duplicate UNIFIED_NETCODE usages

* update

Only assign the server or host world to NetCode.Netcode.Instance.m_ActiveWorld

* fix

Don't run hybrid yet until we merge our N4E changes into trunk.
This also requires modifying anything in CI that automatically creates a test project such that the N4E NetcodeConfig exists and the build settings are set to Client and Server.

* Remove uneeded changes

* update - clean up

Cleaning up some areas.
Wrapping all of the original network prefab unified work where NGO handles the timing for hybrid prefab registration.
(We might remove this prior to release but keeping it for reference purposes in case there are changes on N4E side that require us to use the original approach)
Fixing issue with not removing Rigidbody on clients automatically. (for now until we can make it an opt-in)

* style - fixes

Fixing some style related issues.
Updating the UnifiedBootstrap comment.

* style

Adding some additional comments in various places to help clarify a bit more what is happening.

* style

removing xml-api trailing space.

* UnifiedNetcodeTransport refactor (#3976)

* Fix DontDestroyOnLoadTest

* [MTT-14843] Refactor sending and receiving of N4E RPCs in UnifiedNetcodeTransport to not use entities (#3943)

Refactor sending and receiving of RPCs to not use entities, thereby preserving send/receive order without having to encode an order value and reorder messages on the receive side.

* Post-merge fixes

* Fix remaining errors.

* Revert unnecessary change from bad merge.

* Accidentally deleted a line.

* style

Fixing issue with improperly formatted script when UNIFIED_NETCODE is not defined.

* style - APV fix

Removing all trailing spaces from UnifiedNetcodeTransport.

* Fixed disconnects not being processed correctly in the unified transport

* update

Part of the hybrid spawned parenting fixes.

* Move ghost spawning to GhostSpawnManager

* Fix standards check

* Update com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs

Co-authored-by: Emma <emma.mcmillan@unity3d.com>

* Apply suggestions from code review

Co-authored-by: Emma <emma.mcmillan@unity3d.com>

* update

Updating CreateObjectMessage to use the new GhostSpawnManager.
Removing unused local/cached NetworkSpawnManager var.

* update

Re-enabling log level catch

* update

Moved `PendingGhostSpawnEntry` into the GhostSpawnManager.cs file.
Made `PendingGhostSpawnEntry` implement `IDisposable` for simplification and best practices purposes.

* Update com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/UnifiedNetworkTransformTest.cs

Co-authored-by: Emma <emma.mcmillan@unity3d.com>

---------

Co-authored-by: Kitty Draper <kitty.draper@unity3d.com>
Co-authored-by: Emma <emma.mcmillan@unity3d.com>
Co-authored-by: Kitty Draper <284434+ShadauxCat@users.noreply.github.com>
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.

3 participants