Skip to content

Commit 6115250

Browse files
Merge develop-2.0.0 into chore/merge-2-3-0-back-to-develop-2-0-0
2 parents 62f9aa8 + fe532aa commit 6115250

23 files changed

+403
-151
lines changed

com.unity.netcode.gameobjects/Runtime/Components/AnticipatedNetworkTransform.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ private void ProcessSmoothing()
286286
// TODO: This does not handle OnFixedUpdate
287287
// This requires a complete overhaul in this class to switch between using
288288
// NetworkRigidbody's position and rotation values.
289+
/// <inheritdoc/>
289290
public override void OnUpdate()
290291
{
291292
ProcessSmoothing();
@@ -422,6 +423,7 @@ protected internal override void InternalOnNetworkPostSpawn()
422423
}
423424
}
424425

426+
/// <inheritdoc/>
425427
public override void OnNetworkSpawn()
426428
{
427429
if (NetworkManager.DistributedAuthorityMode)
@@ -445,6 +447,7 @@ public override void OnNetworkSpawn()
445447
NetworkManager.AnticipationSystem.AllAnticipatedObjects.Add(m_AnticipatedObject);
446448
}
447449

450+
/// <inheritdoc/>
448451
public override void OnNetworkDespawn()
449452
{
450453
if (m_AnticipatedObject != null)
@@ -459,6 +462,7 @@ public override void OnNetworkDespawn()
459462
base.OnNetworkDespawn();
460463
}
461464

465+
/// <inheritdoc/>
462466
public override void OnDestroy()
463467
{
464468
if (m_AnticipatedObject != null)
@@ -510,19 +514,22 @@ public void Smooth(TransformState from, TransformState to, float durationSeconds
510514
m_CurrentSmoothTime = 0;
511515
}
512516

517+
/// <inheritdoc/>
513518
protected override void OnBeforeUpdateTransformState()
514519
{
515520
// this is called when new data comes from the server
516521
m_LastAuthorityUpdateCounter = NetworkManager.AnticipationSystem.LastAnticipationAck;
517522
m_OutstandingAuthorityChange = true;
518523
}
519524

525+
/// <inheritdoc/>
520526
protected override void OnNetworkTransformStateUpdated(ref NetworkTransformState oldState, ref NetworkTransformState newState)
521527
{
522528
base.OnNetworkTransformStateUpdated(ref oldState, ref newState);
523529
ApplyAuthoritativeState();
524530
}
525531

532+
/// <inheritdoc/>
526533
protected override void OnTransformUpdated()
527534
{
528535
if (CanCommitToTransform || m_AnticipatedObject == null)

com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public class NetworkConfig
3939
[Tooltip("When set, NetworkManager will automatically create and spawn the assigned player prefab. This can be overridden by adding it to the NetworkPrefabs list and selecting override.")]
4040
public GameObject PlayerPrefab;
4141

42+
/// <summary>
43+
/// The collection of network prefabs that can be spawned across the network
44+
/// </summary>
4245
[SerializeField]
4346
public NetworkPrefabs Prefabs = new NetworkPrefabs();
4447

@@ -159,12 +162,21 @@ public class NetworkConfig
159162
/// </summary>
160163
public const int RttWindowSize = 64; // number of slots to use for RTT computations (max number of in-flight packets)
161164

165+
/// <summary>
166+
/// Determines whether to use the client-server or distributed authority network topology
167+
/// </summary>
162168
[Tooltip("Determines whether to use the client-server or distributed authority network topology.")]
163169
public NetworkTopologyTypes NetworkTopology;
164170

171+
/// <summary>
172+
/// Internal flag for Cloud Multiplayer Build service integration
173+
/// </summary>
165174
[HideInInspector]
166175
public bool UseCMBService;
167176

177+
/// <summary>
178+
/// When enabled (default), the player prefab will automatically be spawned client-side upon the client being approved and synchronized
179+
/// </summary>
168180
[Tooltip("When enabled (default), the player prefab will automatically be spawned (client-side) upon the client being approved and synchronized.")]
169181
public bool AutoSpawnPlayerPrefabClientSide = true;
170182

@@ -205,7 +217,7 @@ internal NetworkConfig Copy()
205217
return networkConfig;
206218
}
207219

208-
#endif
220+
#endif
209221

210222

211223
#if MULTIPLAYER_TOOLS

com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefab.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public class NetworkPrefab
5757
/// </summary>
5858
public GameObject OverridingTargetPrefab;
5959

60+
/// <summary>
61+
/// Compares this NetworkPrefab with another to determine equality
62+
/// </summary>
63+
/// <param name="other">The NetworkPrefab to compare against</param>
64+
/// <returns>True if all fields match between the two NetworkPrefabs, false otherwise</returns>
6065
public bool Equals(NetworkPrefab other)
6166
{
6267
return Override == other.Override &&
@@ -66,6 +71,12 @@ public bool Equals(NetworkPrefab other)
6671
OverridingTargetPrefab == other.OverridingTargetPrefab;
6772
}
6873

74+
/// <summary>
75+
/// Gets the GlobalObjectIdHash of the source prefab based on the current override settings
76+
/// </summary>
77+
/// <value>The hash value identifying the source prefab</value>
78+
/// <exception cref="InvalidOperationException">Thrown when required prefab references are missing or invalid</exception>
79+
/// <exception cref="ArgumentOutOfRangeException">Thrown when Override has an invalid value</exception>
6980
public uint SourcePrefabGlobalObjectIdHash
7081
{
7182
get
@@ -98,6 +109,12 @@ public uint SourcePrefabGlobalObjectIdHash
98109
}
99110
}
100111

112+
/// <summary>
113+
/// Gets the GlobalObjectIdHash of the target prefab when using prefab overrides
114+
/// </summary>
115+
/// <value>The hash value identifying the target prefab, or 0 if no override is set</value>
116+
/// <exception cref="InvalidOperationException">Thrown when required prefab references are missing or invalid</exception>
117+
/// <exception cref="ArgumentOutOfRangeException">Thrown when Override has an invalid value</exception>
101118
public uint TargetPrefabGlobalObjectIdHash
102119
{
103120
get
@@ -122,6 +139,11 @@ public uint TargetPrefabGlobalObjectIdHash
122139
}
123140
}
124141

142+
/// <summary>
143+
/// Validates the NetworkPrefab configuration to ensure all required fields are properly set
144+
/// </summary>
145+
/// <param name="index">Optional index used for error reporting when validating lists of prefabs</param>
146+
/// <returns>True if the NetworkPrefab is valid and ready for use, false otherwise</returns>
125147
public bool Validate(int index = -1)
126148
{
127149
NetworkObject networkObject;
@@ -224,6 +246,10 @@ public bool Validate(int index = -1)
224246
return true;
225247
}
226248

249+
/// <summary>
250+
/// Returns a string representation of this NetworkPrefab's source and target hash values
251+
/// </summary>
252+
/// <returns>A string containing the source and target hash values</returns>
227253
public override string ToString()
228254
{
229255
return $"{{SourceHash: {SourceHashToOverride}, TargetHash: {TargetPrefabGlobalObjectIdHash}}}";

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public class NetworkPrefabs
3939
[NonSerialized]
4040
public Dictionary<uint, uint> OverrideToNetworkPrefab = new Dictionary<uint, uint>();
4141

42+
/// <summary>
43+
/// Gets the read-only list of all registered network prefabs
44+
/// </summary>
4245
public IReadOnlyList<NetworkPrefab> Prefabs => m_Prefabs;
4346

4447
[NonSerialized]
@@ -62,6 +65,9 @@ private void RemoveTriggeredByNetworkPrefabList(NetworkPrefab networkPrefab)
6265
m_Prefabs.Remove(networkPrefab);
6366
}
6467

68+
/// <summary>
69+
/// Finalizer that ensures proper cleanup of network prefab resources
70+
/// </summary>
6571
~NetworkPrefabs()
6672
{
6773
Shutdown();
@@ -84,6 +90,7 @@ internal void Shutdown()
8490
/// Processes the <see cref="NetworkPrefabsList"/> if one is present for use during runtime execution,
8591
/// else processes <see cref="Prefabs"/>.
8692
/// </summary>
93+
/// <param name="warnInvalid">When true, logs warnings about invalid prefabs that are removed during initialization</param>
8794
public void Initialize(bool warnInvalid = true)
8895
{
8996
m_Prefabs.Clear();
@@ -156,6 +163,8 @@ public void Initialize(bool warnInvalid = true)
156163
/// <summary>
157164
/// Add a new NetworkPrefab instance to the list
158165
/// </summary>
166+
/// <param name="networkPrefab">The NetworkPrefab to add</param>
167+
/// <returns>True if the prefab was successfully added, false if it was invalid or already registered</returns>
159168
/// <remarks>
160169
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
161170
///
@@ -177,6 +186,7 @@ public bool Add(NetworkPrefab networkPrefab)
177186
/// <summary>
178187
/// Remove a NetworkPrefab instance from the list
179188
/// </summary>
189+
/// <param name="prefab">The NetworkPrefab to remove</param>
180190
/// <remarks>
181191
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
182192
///
@@ -199,6 +209,7 @@ public void Remove(NetworkPrefab prefab)
199209
/// <summary>
200210
/// Remove a NetworkPrefab instance with matching <see cref="NetworkPrefab.Prefab"/> from the list
201211
/// </summary>
212+
/// <param name="prefab">The GameObject to match against for removal</param>
202213
/// <remarks>
203214
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
204215
///

com.unity.netcode.gameobjects/Runtime/Connection/NetworkClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ public class NetworkClient
3434
/// </summary>
3535
internal bool IsApproved { get; set; }
3636

37+
/// <summary>
38+
/// Defines the network topology type being used for the current network session
39+
/// </summary>
3740
public NetworkTopologyTypes NetworkTopologyType { get; internal set; }
3841

42+
/// <summary>
43+
/// Indicates whether this client is running in Distributed Authority Host mode
44+
/// </summary>
3945
public bool DAHost { get; internal set; }
4046

4147
/// <summary>

com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public enum ConnectionEvent
6060
/// </remarks>
6161
public struct ConnectionEventData
6262
{
63+
/// <summary>
64+
/// The type of connection event that occurred
65+
/// </summary>
6366
public ConnectionEvent EventType;
6467

6568
/// <summary>

com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66

77
namespace Unity.Netcode
88
{
9+
/// <summary>
10+
/// Exception thrown when an RPC (Remote Procedure Call) encounters an error during execution
11+
/// </summary>
912
public class RpcException : Exception
1013
{
14+
/// <summary>
15+
/// Initializes a new instance of the RpcException class with a specified error message
16+
/// </summary>
17+
/// <param name="message">The message that describes the error</param>
1118
public RpcException(string message) : base(message)
1219
{
1320

@@ -694,6 +701,9 @@ public virtual void OnNetworkSpawn() { }
694701
/// </remarks>
695702
protected virtual void OnNetworkPostSpawn() { }
696703

704+
/// <summary>
705+
/// Internal implementation of post-spawn functionality. Called after OnNetworkSpawn to handle internal post-spawn operations.
706+
/// </summary>
697707
protected internal virtual void InternalOnNetworkPostSpawn() { }
698708

699709
/// <summary>
@@ -708,6 +718,9 @@ protected internal virtual void InternalOnNetworkPostSpawn() { }
708718
/// </remarks>
709719
protected virtual void OnNetworkSessionSynchronized() { }
710720

721+
/// <summary>
722+
/// Internal implementation of network session synchronization. Handles the internal processing of session synchronization events.
723+
/// </summary>
711724
protected internal virtual void InternalOnNetworkSessionSynchronized() { }
712725

713726
/// <summary>
@@ -1386,6 +1399,11 @@ protected virtual void OnSynchronize<T>(ref BufferSerializer<T> serializer) wher
13861399

13871400
}
13881401

1402+
/// <summary>
1403+
/// Called when network conditions require reanticipation of game state.
1404+
/// Override this method to handle adjustments needed when network latency changes.
1405+
/// </summary>
1406+
/// <param name="lastRoundTripTime">The most recent round trip time measurement in seconds</param>
13891407
public virtual void OnReanticipate(double lastRoundTripTime)
13901408
{
13911409

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ internal void HandleRedistributionToClients()
201201

202202
internal List<NetworkObject> DeferredDespawnObjects = new List<NetworkObject>();
203203

204+
/// <summary>
205+
/// Gets the client identifier of the current session owner in distributed authority mode
206+
/// </summary>
204207
public ulong CurrentSessionOwner { get; internal set; }
205208

206209
/// <summary>
@@ -312,6 +315,10 @@ private void UpdateTopology()
312315
}
313316
}
314317

318+
/// <summary>
319+
/// Processes network-related updates for a specific update stage in the frame
320+
/// </summary>
321+
/// <param name="updateStage">The current network update stage being processed</param>
315322
public void NetworkUpdate(NetworkUpdateStage updateStage)
316323
{
317324
switch (updateStage)
@@ -643,6 +650,10 @@ public event Action OnTransportFailure
643650
remove => ConnectionManager.OnTransportFailure -= value;
644651
}
645652

653+
/// <summary>
654+
/// Delegate for handling network state reanticipation events
655+
/// </summary>
656+
/// <param name="lastRoundTripTime">The most recent round-trip time measurement in seconds between client and server</param>
646657
public delegate void ReanticipateDelegate(double lastRoundTripTime);
647658

648659
/// <summary>

0 commit comments

Comments
 (0)