-
Notifications
You must be signed in to change notification settings - Fork 461
feat: Unified Netcode POC migration #3963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NoelStephensUnity
merged 155 commits into
develop-3.x.x
from
experimental/v3-x-x/unified-poc-migration
Jun 2, 2026
Merged
Changes from all commits
Commits
Show all changes
155 commits
Select commit
Hold shift + click to select a range
2973bb9
update
NoelStephensUnity 3190354
Merge branch 'develop' into experimental/ngo-and-n4e
NoelStephensUnity d0b7f1c
Merge remote-tracking branch 'origin/develop-2.0.0' into experimental…
NoelStephensUnity 2eeb2c7
update - wip
NoelStephensUnity fb7d11a
update
NoelStephensUnity aa6ea10
Merge branch 'develop-2.0.0' into experimental/v2-x-x/ngo-and-n4e
NoelStephensUnity c15498c
update
NoelStephensUnity 83e3c62
update
NoelStephensUnity dd4a95c
update
NoelStephensUnity d759121
update
NoelStephensUnity ba19e82
update
NoelStephensUnity c6e2fd9
fix
NoelStephensUnity a97064b
fix
NoelStephensUnity 9deb6ec
update
NoelStephensUnity b9446a4
update
NoelStephensUnity 187d6ea
update
NoelStephensUnity cc5c3a6
update
NoelStephensUnity bae60bb
Merge branch 'develop-2.0.0' into experimental/v2-x-x/ngo-and-n4e
NoelStephensUnity 5cfc6c2
update
NoelStephensUnity ec01428
update
NoelStephensUnity d1f28b5
update
NoelStephensUnity 1dd4bd2
fix
NoelStephensUnity 6cf0413
update
NoelStephensUnity 1f3c7a7
update - child network behaviours
NoelStephensUnity 90559b3
fix
NoelStephensUnity 21143ec
fix
NoelStephensUnity e83eb23
fix
NoelStephensUnity 9546ff2
fix
NoelStephensUnity 211a50f
update
NoelStephensUnity c6315ce
fix & update
NoelStephensUnity 9038909
update
NoelStephensUnity 526f30b
update
NoelStephensUnity ff84ee2
Transport sharing WIP
ShadauxCat ea80eb0
update
NoelStephensUnity 3d4a803
update
NoelStephensUnity a6b852f
update
NoelStephensUnity 0bd4efd
Merge branch 'experimental/v2-x-x/ngo-and-n4e' into experimental/v2-x…
ShadauxCat cce1185
update
NoelStephensUnity adf29e1
Merge branch 'develop-2.0.0' into experimental/v2-x-x/ngo-and-n4e
NoelStephensUnity 91cf538
update
NoelStephensUnity 5802407
update
NoelStephensUnity da1beaf
update
NoelStephensUnity f2f6580
update
NoelStephensUnity b5f232b
Merge branch 'experimental/v2-x-x/ngo-and-n4e' into experimental/v2-x…
ShadauxCat fd1263f
- Delay connections from going in game in N4E until initial NGO sync …
ShadauxCat 8bc8800
Got RTT working correctly.
ShadauxCat ac625b2
update
NoelStephensUnity c31e7c2
Merge branch 'experimental/v2-x-x/ngo-and-n4e' into test-merge/v2-x-x…
NoelStephensUnity 038b157
update & fixes
NoelStephensUnity 1e75ba1
fix
NoelStephensUnity be7b59c
update
NoelStephensUnity 6f575ae
update
NoelStephensUnity 13cbe71
update
NoelStephensUnity 66e6483
Switched TransportRpc to use the Out-Of-Band RPC pipeline
ShadauxCat 2c98801
Merge branch 'experimental/v2-x-x/ngo-and-n4e-kitty' into experimenta…
NoelStephensUnity ebed5f6
update - OUT_OF_BAND_RPC
NoelStephensUnity b14c13b
Merge branch 'develop-2.0.0' into experimental/v3-x-x/unified
NoelStephensUnity 003ae42
update
NoelStephensUnity 4512b39
chore: merge ngo and n4e with poc transport and updates (#3889)
NoelStephensUnity 86e0249
Optimizations of the UnifiedNetcodeTransport.
ShadauxCat d543b03
Merge branch 'experimental/v2-x-x/ngo-and-n4e-kitty' into experimenta…
NoelStephensUnity 4bbda35
Merge branch 'develop-2.0.0' into experimental/v2-x-x/ngo-and-n4e-wit…
NoelStephensUnity 4fc66b5
Merge branch 'experimental/v2-x-x/ngo-and-n4e-with-poc-transport-merg…
NoelStephensUnity 5c9ad50
Added support for surfacing disconnect messages
ShadauxCat 1dc6b39
Merge branch 'experimental/v2-x-x/ngo-and-n4e-kitty' into experimenta…
NoelStephensUnity 205ca97
Merge branch 'experimental/v2-x-x/ngo-and-n4e-with-poc-transport-merg…
NoelStephensUnity b1daa58
fix
NoelStephensUnity 5ea9d4a
fix
NoelStephensUnity 5d9f741
Update NetworkObject.cs
NoelStephensUnity 8ed8666
temp-fix
NoelStephensUnity 13ef013
update
NoelStephensUnity 1c8b43d
update
NoelStephensUnity fe75aa3
Merge branch 'develop-2.0.0' into experimental/v3-x-x/unified
NoelStephensUnity 78874ff
fix
NoelStephensUnity 164a713
Integration tests WIP
ShadauxCat 0cc6391
Removed SetActive calls
ShadauxCat 4308345
update
NoelStephensUnity 2916b67
style
NoelStephensUnity 59f8208
update
NoelStephensUnity ab1addf
Merge branch 'develop-2.0.0' into experimental/v3-x-x/hybrid_spawn_in…
NoelStephensUnity 453c8e2
update
NoelStephensUnity a4e7bab
fix:
NoelStephensUnity 7c87a87
update
NoelStephensUnity b80b0c3
test-fix
NoelStephensUnity 8c76504
test-fix
NoelStephensUnity 25576e3
fix
NoelStephensUnity 61688b9
update
NoelStephensUnity 481ff8e
fix
NoelStephensUnity 707c439
Merge branch 'develop-3.x.x' into experimental/v3-x-x/hybrid_spawn_in…
NoelStephensUnity 779afef
update - remove NGO-N4E-Example
NoelStephensUnity 00b140c
update
NoelStephensUnity 05138a4
update
NoelStephensUnity e66c22e
update
NoelStephensUnity bf4f27c
update
NoelStephensUnity abcb4a6
update & style
NoelStephensUnity ad90421
test
NoelStephensUnity 9858362
style
NoelStephensUnity 71a5af5
update - Multiprocess Runtime
NoelStephensUnity 570dcb7
fix
NoelStephensUnity 7f1b592
update
NoelStephensUnity b599a1f
update
NoelStephensUnity a5b5e89
style - PVP-124-2
NoelStephensUnity 17f0a17
update: PVP-Exceptions
NoelStephensUnity 5fb2d14
fix
NoelStephensUnity 0d15bf7
fix
NoelStephensUnity 0333853
fix
NoelStephensUnity cdb89eb
style
NoelStephensUnity 5a6d19c
update
NoelStephensUnity 712161c
style
NoelStephensUnity 077f183
revert
NoelStephensUnity 78e36cb
style
NoelStephensUnity 560bf37
style
NoelStephensUnity c95a3f0
update
NoelStephensUnity 9f70c40
Update
NoelStephensUnity 6067a31
update
NoelStephensUnity 29d4124
style
NoelStephensUnity 2c7d039
update
NoelStephensUnity f0046b4
Merge branch 'develop-2.0.0' into experimental/v3-x-x/unified-poc-mig…
NoelStephensUnity 9bd899c
Merge branch 'develop-2.0.0' into experimental/v3-x-x/unified-poc-mig…
NoelStephensUnity d07687d
Added hybrid spawning to a bunch of existing tests and fixed most of …
ShadauxCat 2578615
Merge branch 'experimental/v3-x-x/hybrid_spawn_integration_tests' int…
NoelStephensUnity e1e79dc
update
NoelStephensUnity df2226b
style - PVP
NoelStephensUnity 467e26c
Merge branch 'develop-3.x.x' into experimental/v3-x-x/unified-poc-mig…
NoelStephensUnity 34acb92
style
NoelStephensUnity 003e577
Merge branch 'develop-3.x.x' into experimental/v3-x-x/unified-poc-mig…
EmandM 3be0719
update
NoelStephensUnity fecd845
Update & Fix
NoelStephensUnity cea8ac5
Merge branch 'develop-3.x.x' into experimental/v3-x-x/unified-poc-mig…
EmandM b8c41c5
small merge fixes
EmandM 3fc9a09
test
NoelStephensUnity 206d52e
Merge branch 'experimental/v3-x-x/unified-poc-migration' of https://g…
NoelStephensUnity 86b5ade
update
NoelStephensUnity 2409559
update
NoelStephensUnity cf8fbe6
fix
NoelStephensUnity c1ea3ba
Merge branch 'develop-3.x.x' into experimental/v3-x-x/unified-poc-mig…
EmandM eae82d8
Remove uneeded changes
EmandM c45de18
Merge branch 'develop-3.x.x' into experimental/v3-x-x/unified-poc-mig…
NoelStephensUnity e294325
update - clean up
NoelStephensUnity 6494ff4
style - fixes
NoelStephensUnity 9eac4dd
style
NoelStephensUnity 6361bb3
style
NoelStephensUnity 1d4e514
UnifiedNetcodeTransport refactor (#3976)
ShadauxCat 868a424
style
NoelStephensUnity 774e103
style - APV fix
NoelStephensUnity bdf68c5
Fixed disconnects not being processed correctly in the unified transport
ShadauxCat 7b528d4
update
NoelStephensUnity 9ee8fad
Move ghost spawning to GhostSpawnManager
EmandM 8571cd1
Fix standards check
EmandM b3bf6b3
Update com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPre…
NoelStephensUnity 65c25a1
Apply suggestions from code review
NoelStephensUnity b0a5208
update
NoelStephensUnity 29e08c6
update
NoelStephensUnity fe4cff9
update
NoelStephensUnity d282be3
Update com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/U…
NoelStephensUnity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
com.unity.netcode.gameobjects/Runtime/Components/Helpers/NetworkObjectBridge.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #if UNIFIED_NETCODE | ||
| using Unity.NetCode; | ||
| #if UNITY_EDITOR | ||
| using UnityEditor; | ||
| #endif | ||
| using UnityEngine; | ||
|
|
||
| namespace Unity.Netcode | ||
| { | ||
| /// <summary> | ||
| /// TODO-UNIFIED: Needs further peer review and exploring alternate ways of handling this. | ||
| /// This is a component that is added to the root of all N4E-spawned hybrid prefab instances. It is used to link | ||
| /// <see cref="NetworkObject.SerializedObject"/> the N4E-spawned hybrid prefab instances to the incoming <see cref="CreateObjectMessage"/> | ||
| /// specific to the N4E-spawned hybrid prefab instance that has the matching <see cref="NetworkObjectId"/>. | ||
| /// </summary> | ||
| public partial class NetworkObjectBridge : GhostBehaviour | ||
| { | ||
| #if UNITY_EDITOR | ||
| [HideInInspector] | ||
| [SerializeField] | ||
| private bool m_Sorted = false; | ||
| private void OnValidate() | ||
| { | ||
| // TODO-UNIFIED: GhostAdapter must be above all GhostBehaviours in order to assure the GhostAdapter is initialized before any GhostBehaviour. | ||
| // This auto-sorting is required because the GhostBehaviours rely on the GhostAdapter.Awake being invoked before any GhostBehaviour.Awake. | ||
| if (!m_Sorted && !EditorApplication.isPlaying) | ||
| { | ||
| while (UnityEditorInternal.ComponentUtility.MoveComponentUp(this)) | ||
| { | ||
| // Keep moving until it can't go higher | ||
| } | ||
| var ghostAdapter = gameObject.GetComponent<GhostAdapter>(); | ||
| // Now move the GhostAdapter to the top so it is above NetworkObjectBridge | ||
| while (ghostAdapter != null && UnityEditorInternal.ComponentUtility.MoveComponentUp(ghostAdapter)) | ||
| { | ||
| // Keep moving until it can't go higher | ||
| } | ||
|
|
||
| m_Sorted = true; | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
| /// <summary> | ||
| /// This is used to link <see cref="NetworkObject.SerializedObject"/> data to | ||
| /// N4E-spawned hybrid prefab instances. | ||
| /// </summary> | ||
| internal GhostField<ulong> NetworkObjectId = new GhostField<ulong>(); | ||
| public void SetNetworkObjectId(ulong networkObjectId) | ||
| { | ||
| NetworkObjectId.PresetValue(networkObjectId); | ||
| NetworkObjectId.Value = networkObjectId; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Currently, NGO provides the parenting event handling via <see cref="ParentSyncMessage"/>. | ||
| /// Once <see cref="GhostField{InternalTypeT}"/> can provide a form of event notification that | ||
| /// the value has changed, we can then invert this flow such that the change in the parent value | ||
| /// drives the event. | ||
| /// </summary> | ||
| /// <param name="scale">We use NGO scale, delivered via ParentSyncMessage, that is applied to this | ||
| /// instance's entity's PostTransformMatrix.</param> | ||
| internal void HybridParentUpdate(Vector3 scale) | ||
| { | ||
| var current = Ghost.GetPositionAndRotation(); | ||
| //Debug.Log($"---- Current LT: {current.Position} | {current.Rotation.eulerAngles}"); | ||
| //Debug.Log($"---- New LT: {transform.localPosition} | {transform.localRotation}"); | ||
| Ghost.ApplyPostTransformMatrixScale(scale); | ||
| } | ||
| } | ||
| } | ||
| #endif | ||
11 changes: 11 additions & 0 deletions
11
com.unity.netcode.gameobjects/Runtime/Components/Helpers/NetworkObjectBridge.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
com.unity.netcode.gameobjects/Runtime/Components/Helpers/UnifiedBootstrap.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| #if UNIFIED_NETCODE | ||
| using System; | ||
| using Unity.Entities; | ||
| using Unity.NetCode; | ||
| using UnityEngine; | ||
|
|
||
| namespace Unity.Netcode | ||
| { | ||
| /// <summary> | ||
| /// TODO-UNIFIED: Needs furthery review and proper error messaging using the new logging context. | ||
| /// Handles the bootstrap process for both client and server in unified mode. This is used to create the world and set it on the | ||
| /// NetworkManager during initialization. | ||
| /// </summary> | ||
| internal class UnifiedBootstrap : ClientServerBootstrap | ||
| { | ||
| public static UnifiedBootstrap Instance { get; private set; } | ||
| public static Action OnInitialized; | ||
| public static ushort Port = 7979; | ||
| public static NetworkManager CurrentNetworkManagerForInitialization; | ||
|
|
||
| public static World LastCreatedWorld { get; private set; } | ||
|
|
||
| private static int s_WorldCounter = 0; | ||
|
|
||
| public override bool Initialize(string defaultWorldName) | ||
| { | ||
| var networkManager = CurrentNetworkManagerForInitialization; | ||
| if (networkManager == NetworkManager.Singleton) | ||
| { | ||
| Instance = this; | ||
| } | ||
|
|
||
| AutoConnectPort = Port; | ||
| if (base.Initialize(defaultWorldName)) | ||
| { | ||
| Debug.LogError($"[{nameof(UnifiedBootstrap)}] Auto-bootstrap is enabled!!! This will break the POC!"); | ||
| return true; | ||
| } | ||
|
|
||
| if (networkManager != null) | ||
| { | ||
| Debug.Log($"Starting a world for {(networkManager.IsServer ? "Host" : "Client")}"); | ||
| s_WorldCounter++; | ||
| LastCreatedWorld = networkManager.IsServer ? CreateSingleWorldHost($"HostSingleWorld-{s_WorldCounter}") | ||
| : CreateClientWorld($"ClientWorld-{s_WorldCounter}"); | ||
|
|
||
| if (LastCreatedWorld == null) | ||
| { | ||
| s_WorldCounter--; | ||
| Debug.LogError($"[{nameof(UnifiedBootstrap)}] World is null!"); | ||
| return false; | ||
| } | ||
|
|
||
| if (!LastCreatedWorld.IsCreated) | ||
| { | ||
| s_WorldCounter--; | ||
| Debug.LogError($"[{nameof(UnifiedBootstrap)}] World was not created!"); | ||
| return false; | ||
| } | ||
|
|
||
| if (networkManager.LogLevel <= LogLevel.Developer) | ||
| { | ||
| NetworkLog.LogInfo($"[{nameof(UnifiedBootstrap)}] Created world: {LastCreatedWorld.Name} / {LastCreatedWorld.SequenceNumber}"); | ||
| } | ||
|
|
||
| networkManager.NetcodeWorld = (NetcodeWorld)LastCreatedWorld; | ||
| #if UNIFIED_NGO_REGISTERS_PREFABS | ||
| if (networkManager.NetworkConfig.Prefabs.HasPendingGhostPrefabs) | ||
| { | ||
| if (networkManager.LogLevel <= LogLevel.Developer) | ||
| { | ||
| NetworkLog.LogInfo($"[{nameof(UnifiedBootstrap)}] Registering hybrid prefabs..."); | ||
| } | ||
| networkManager.NetworkConfig.Prefabs.RegisterGhostPrefabs(networkManager); | ||
| } | ||
| #endif | ||
| } | ||
| else | ||
| { | ||
| LastCreatedWorld = CreateLocalWorld("LocalWorld"); | ||
| } | ||
|
|
||
| OnInitialized?.Invoke(); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| ~UnifiedBootstrap() | ||
| { | ||
| LastCreatedWorld = null; | ||
| Instance = null; | ||
| } | ||
| } | ||
| } | ||
| #endif |
2 changes: 2 additions & 0 deletions
2
com.unity.netcode.gameobjects/Runtime/Components/Helpers/UnifiedBootstrap.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
129 changes: 129 additions & 0 deletions
129
com.unity.netcode.gameobjects/Runtime/Components/Helpers/UnifiedUpdateConnections.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| #if UNIFIED_NETCODE | ||
| using System.Collections.Generic; | ||
| using Unity.Collections; | ||
| using Unity.Entities; | ||
| using Unity.NetCode; | ||
| using UnityEngine; | ||
|
|
||
| namespace Unity.Netcode.Components | ||
| { | ||
|
|
||
| public struct NetcodeConnection | ||
| { | ||
| internal World World; | ||
| internal Entity Entity; | ||
| public int NetworkId; | ||
|
|
||
| public bool IsServer => World.IsServer(); | ||
| public void GoInGame() | ||
| { | ||
| World.EntityManager.AddComponentData(Entity, default(NetworkStreamInGame)); | ||
| } | ||
| public void SendMessage<T>(T message) where T : unmanaged, IRpcCommand | ||
| { | ||
| var req = World.EntityManager.CreateEntity(); | ||
| World.EntityManager.AddComponentData(req, new SendRpcCommandRequest { TargetConnection = Entity }); | ||
| World.EntityManager.AddComponentData(req, message); | ||
| } | ||
| } | ||
|
|
||
| internal partial class UnifiedUpdateConnections : SystemBase | ||
| { | ||
| private List<NetcodeConnection> m_TempConnections = new List<NetcodeConnection>(); | ||
|
|
||
| private Dictionary<int, NetcodeConnection> m_NewConnections = new Dictionary<int, NetcodeConnection>(); | ||
|
|
||
| protected override void OnUpdate() | ||
| { | ||
| var isServer = World.IsServer(); | ||
| var commandBuffer = new EntityCommandBuffer(Allocator.Temp); | ||
| foreach (var networkManager in Object.FindObjectsByType<NetworkManager>()) | ||
| { | ||
| foreach (var (networkId, connectionState, entity) in SystemAPI.Query<NetworkId, ConnectionState>().WithNone<NetworkStreamConnection>().WithEntityAccess()) | ||
| { | ||
| commandBuffer.RemoveComponent<ConnectionState>(entity); | ||
| m_TempConnections.Add(new NetcodeConnection | ||
| { | ||
| World = World, | ||
| Entity = entity, | ||
| NetworkId = networkId.Value | ||
| }); | ||
| } | ||
|
|
||
| foreach (var con in m_TempConnections) | ||
| { | ||
| NetworkManager.OnNetCodeDisconnect?.Invoke(con); | ||
| } | ||
|
|
||
| m_TempConnections.Clear(); | ||
|
|
||
| // TODO: We should figure out how to associate the N4E NetworkId with the NGO ClientId | ||
| foreach (var (networkId, entity) in SystemAPI.Query<NetworkId>().WithAll<NetworkStreamConnection>() | ||
| .WithNone<NetworkStreamInGame>().WithEntityAccess()) | ||
| { | ||
| if (!m_NewConnections.ContainsKey(networkId.Value)) | ||
| { | ||
| var newConnection = new NetcodeConnection | ||
| { World = World, Entity = entity, NetworkId = networkId.Value }; | ||
| m_NewConnections.Add(networkId.Value, newConnection); | ||
| } | ||
| } | ||
|
|
||
| // If we have any pending connections | ||
| if (m_NewConnections.Count > 0) | ||
| { | ||
| foreach (var entry in m_NewConnections) | ||
| { | ||
| // Server: always connect | ||
| // Client: wait until we have synchronized before announcing we are ready to receive snapshots | ||
| if (networkManager.IsServer || (!networkManager.IsServer && networkManager.IsConnectedClient)) | ||
| { | ||
| // Set the connection in-game | ||
| commandBuffer.AddComponent<NetworkStreamInGame>(entry.Value.Entity); | ||
| commandBuffer.AddComponent(entry.Value.Entity, default(ConnectionState)); | ||
| NetworkManager.OnNetCodeConnect?.Invoke(entry.Value); | ||
| m_TempConnections.Add(entry.Value); | ||
| } | ||
| } | ||
|
|
||
| // Remove any connections that have "gone in-game". | ||
| foreach (var connection in m_TempConnections) | ||
| { | ||
| m_NewConnections.Remove(connection.NetworkId); | ||
| } | ||
| } | ||
|
|
||
| m_TempConnections.Clear(); | ||
|
|
||
| // If the local NetworkManager is shutting down or no longer connected, then | ||
| // make sure we have disconnected all known connections. | ||
| if (networkManager.ShutdownInProgress || !networkManager.IsListening) | ||
| { | ||
| foreach (var (networkId, entity) in SystemAPI.Query<NetworkId>().WithEntityAccess()) | ||
| { | ||
| commandBuffer.RemoveComponent<ConnectionState>(entity); | ||
| NetworkManager.OnNetCodeDisconnect?.Invoke(new NetcodeConnection | ||
| { World = World, Entity = entity, NetworkId = networkId.Value }); | ||
| } | ||
| } | ||
| } | ||
| commandBuffer.Playback(EntityManager); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Always disconnect all known connections when being destroyed. | ||
| /// </summary> | ||
| protected override void OnDestroy() | ||
| { | ||
| var commandBuffer = new EntityCommandBuffer(Allocator.Temp); | ||
| foreach (var (networkId, entity) in SystemAPI.Query<NetworkId>().WithEntityAccess()) | ||
| { | ||
| commandBuffer.RemoveComponent<ConnectionState>(entity); | ||
| NetworkManager.OnNetCodeDisconnect?.Invoke(new NetcodeConnection { World = World, Entity = entity, NetworkId = networkId.Value }); | ||
| } | ||
| commandBuffer.Playback(EntityManager); | ||
| base.OnDestroy(); | ||
| } | ||
| } | ||
| } | ||
| #endif |
2 changes: 2 additions & 0 deletions
2
com.unity.netcode.gameobjects/Runtime/Components/Helpers/UnifiedUpdateConnections.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.