diff --git a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs
index 7c3cb964af..85f9acd311 100644
--- a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs
@@ -31,6 +31,9 @@ public class NetworkConfig
[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.")]
public GameObject PlayerPrefab;
+ ///
+ /// The collection of network prefabs available for spawning across the network
+ ///
[SerializeField]
public NetworkPrefabs Prefabs = new NetworkPrefabs();
diff --git a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefab.cs b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefab.cs
index 9cc2158cc1..c6f30d2835 100644
--- a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefab.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefab.cs
@@ -57,6 +57,11 @@ public class NetworkPrefab
///
public GameObject OverridingTargetPrefab;
+ ///
+ /// Compares this NetworkPrefab with another to determine equality
+ ///
+ /// The NetworkPrefab to compare against
+ /// True if all fields match between the two NetworkPrefabs, false otherwise
public bool Equals(NetworkPrefab other)
{
return Override == other.Override &&
@@ -66,6 +71,12 @@ public bool Equals(NetworkPrefab other)
OverridingTargetPrefab == other.OverridingTargetPrefab;
}
+ ///
+ /// Gets the GlobalObjectIdHash of the source prefab based on the current override settings
+ ///
+ /// The hash value identifying the source prefab
+ /// Thrown when required prefab references are missing or invalid
+ /// Thrown when Override has an invalid value
public uint SourcePrefabGlobalObjectIdHash
{
get
@@ -98,6 +109,12 @@ public uint SourcePrefabGlobalObjectIdHash
}
}
+ ///
+ /// Gets the GlobalObjectIdHash of the target prefab when using prefab overrides
+ ///
+ /// The hash value identifying the target prefab, or 0 if no override is set
+ /// Thrown when required prefab references are missing or invalid
+ /// Thrown when Override has an invalid value
public uint TargetPrefabGlobalObjectIdHash
{
get
@@ -122,6 +139,11 @@ public uint TargetPrefabGlobalObjectIdHash
}
}
+ ///
+ /// Validates the NetworkPrefab configuration to ensure all required fields are properly set
+ ///
+ /// Optional index used for error reporting when validating lists of prefabs
+ /// True if the NetworkPrefab is valid and ready for use, false otherwise
public bool Validate(int index = -1)
{
NetworkObject networkObject;
@@ -224,6 +246,10 @@ public bool Validate(int index = -1)
return true;
}
+ ///
+ /// Returns a string representation of this NetworkPrefab's source and target hash values
+ ///
+ /// A string containing the source and target hash values
public override string ToString()
{
return $"{{SourceHash: {SourceHashToOverride}, TargetHash: {TargetPrefabGlobalObjectIdHash}}}";
diff --git a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs
index 42758f7e78..6e801f5b61 100644
--- a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs
@@ -39,6 +39,9 @@ public class NetworkPrefabs
[NonSerialized]
public Dictionary OverrideToNetworkPrefab = new Dictionary();
+ ///
+ /// Gets the read-only list of all registered network prefabs
+ ///
public IReadOnlyList Prefabs => m_Prefabs;
[NonSerialized]
@@ -62,6 +65,9 @@ private void RemoveTriggeredByNetworkPrefabList(NetworkPrefab networkPrefab)
m_Prefabs.Remove(networkPrefab);
}
+ ///
+ /// Finalizer that ensures proper cleanup of network prefab resources
+ ///
~NetworkPrefabs()
{
Shutdown();
@@ -84,6 +90,7 @@ internal void Shutdown()
/// Processes the if one is present for use during runtime execution,
/// else processes .
///
+ /// When true, logs warnings about invalid prefabs that are removed during initialization
public void Initialize(bool warnInvalid = true)
{
m_Prefabs.Clear();
@@ -156,6 +163,8 @@ public void Initialize(bool warnInvalid = true)
///
/// Add a new NetworkPrefab instance to the list
///
+ /// The NetworkPrefab to add
+ /// True if the prefab was successfully added, false if it was invalid or already registered
///
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
///
@@ -177,6 +186,7 @@ public bool Add(NetworkPrefab networkPrefab)
///
/// Remove a NetworkPrefab instance from the list
///
+ /// The NetworkPrefab to remove
///
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
///
@@ -199,6 +209,7 @@ public void Remove(NetworkPrefab prefab)
///
/// Remove a NetworkPrefab instance with matching from the list
///
+ /// The GameObject to match against for removal
///
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
///
diff --git a/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs b/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs
index fb56d762e5..97486a8ba7 100644
--- a/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs
@@ -11,7 +11,7 @@
namespace Unity.Netcode
{
///
- /// The connection event type set within to signify the type of connection event notification received.
+ /// The connection event type set within to signify the type of connection event notification received.
///
///
/// is returned as a parameter of the event notification.
@@ -60,6 +60,9 @@ public enum ConnectionEvent
///
public struct ConnectionEventData
{
+ ///
+ /// The type of connection event that occurred
+ ///
public ConnectionEvent EventType;
///
diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
index f534351a1b..3db09bcc31 100644
--- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
@@ -6,8 +6,15 @@
namespace Unity.Netcode
{
+ ///
+ /// Exception thrown when an RPC (Remote Procedure Call) encounters an error during execution
+ ///
public class RpcException : Exception
{
+ ///
+ /// Initializes a new instance of the RpcException class with a specified error message
+ ///
+ /// The message that describes the error
public RpcException(string message) : base(message)
{
diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs
index b539491533..9478a9de31 100644
--- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs
@@ -44,6 +44,10 @@ public class NetworkManager : MonoBehaviour, INetworkUpdateSystem
#pragma warning restore IDE1006 // restore naming rule violation check
+ ///
+ /// Processes network-related updates for a specific update stage in the frame
+ ///
+ /// The current network update stage being processed
public void NetworkUpdate(NetworkUpdateStage updateStage)
{
switch (updateStage)
@@ -294,6 +298,10 @@ public event Action OnTransportFailure
remove => ConnectionManager.OnTransportFailure -= value;
}
+ ///
+ /// Delegate for handling network state reanticipation events
+ ///
+ /// The most recent round-trip time measurement in seconds between client and server
public delegate void ReanticipateDelegate(double lastRoundTripTime);
///
diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
index 47eca79f97..2c735cc6f2 100644
--- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
@@ -388,6 +388,7 @@ private GlobalObjectId GetGlobalId()
/// Delegate type for checking visibility
///
/// The clientId to check visibility for
+ /// True if the object should be visible to the specified client, false otherwise
public delegate bool VisibilityDelegate(ulong clientId);
///
@@ -399,6 +400,7 @@ private GlobalObjectId GetGlobalId()
/// Delegate type for checking spawn options
///
/// The clientId to check spawn options for
+ /// True if the object should be spawned for the specified client, false otherwise
public delegate bool SpawnDelegate(ulong clientId);
///
@@ -1601,6 +1603,11 @@ internal ushort GetNetworkBehaviourOrderIndex(NetworkBehaviour instance)
return 0;
}
+ ///
+ /// Gets a NetworkBehaviour component at the specified index in this object's NetworkBehaviour list
+ ///
+ /// The zero-based index of the NetworkBehaviour to retrieve
+ /// The NetworkBehaviour at the specified index, or null if the index is out of bounds
public NetworkBehaviour GetNetworkBehaviourAtOrderIndex(ushort index)
{
if (index >= ChildNetworkBehaviours.Count)
diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/CustomMessageManager.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/CustomMessageManager.cs
index 98c344fa19..d7b58ad977 100644
--- a/com.unity.netcode.gameobjects/Runtime/Messaging/CustomMessageManager.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Messaging/CustomMessageManager.cs
@@ -139,6 +139,8 @@ public void SendUnnamedMessage(ulong clientId, FastBufferWriter messageBuffer, N
///
/// Delegate used to handle named messages
///
+ /// The client identifier of the message sender
+ /// The buffer containing the message data to be read
public delegate void HandleNamedMessageDelegate(ulong senderClientId, FastBufferReader messagePayload);
private Dictionary m_NamedMessageHandlers32 = new Dictionary();
diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForGenericParameterAttribute.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForGenericParameterAttribute.cs
index a102f3666e..c8d4cedf45 100644
--- a/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForGenericParameterAttribute.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForGenericParameterAttribute.cs
@@ -74,6 +74,10 @@ public class GenerateSerializationForGenericParameterAttribute : Attribute
{
internal int ParameterIndex;
+ ///
+ /// Initializes a new instance of the attribute
+ ///
+ /// The zero-based index of the generic parameter that should be serialized
public GenerateSerializationForGenericParameterAttribute(int parameterIndex)
{
ParameterIndex = parameterIndex;
diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForTypeAttribute.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForTypeAttribute.cs
index 81e55c00df..5bfff33864 100644
--- a/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForTypeAttribute.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForTypeAttribute.cs
@@ -18,6 +18,10 @@ public class GenerateSerializationForTypeAttribute : Attribute
{
internal Type Type;
+ ///
+ /// Initializes a new instance of the attribute
+ ///
+ /// The type that should have serialization code generated for it
public GenerateSerializationForTypeAttribute(Type type)
{
Type = type;
diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/RpcAttributes.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/RpcAttributes.cs
index acb6289b5b..39432097d4 100644
--- a/com.unity.netcode.gameobjects/Runtime/Messaging/RpcAttributes.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Messaging/RpcAttributes.cs
@@ -25,11 +25,29 @@ public enum RpcDelivery
public class RpcAttribute : Attribute
{
// Must match the set of parameters below
+ ///
+ /// Parameters that define the behavior of an RPC
+ ///
public struct RpcAttributeParams
{
+ ///
+ /// The delivery method for the RPC
+ ///
public RpcDelivery Delivery;
+
+ ///
+ /// When true, only the owner of the object can execute this RPC
+ ///
public bool RequireOwnership;
+
+ ///
+ /// When true, local execution of the RPC is deferred until the next network tick
+ ///
public bool DeferLocal;
+
+ ///
+ /// When true, allows the RPC target to be overridden at runtime
+ ///
public bool AllowTargetOverride;
}
@@ -38,10 +56,26 @@ public struct RpcAttributeParams
/// Type of RPC delivery method
///
public RpcDelivery Delivery = RpcDelivery.Reliable;
+
+ ///
+ /// When true, only the owner of the object can execute this RPC
+ ///
public bool RequireOwnership;
+
+ ///
+ /// When true, local execution of the RPC is deferred until the next network tick
+ ///
public bool DeferLocal;
+
+ ///
+ /// When true, allows the RPC target to be overridden at runtime
+ ///
public bool AllowTargetOverride;
+ ///
+ /// Initializes a new instance of the RpcAttribute with the specified target
+ ///
+ /// The target for this RPC
public RpcAttribute(SendTo target)
{
}
@@ -60,8 +94,14 @@ private RpcAttribute()
[AttributeUsage(AttributeTargets.Method)]
public class ServerRpcAttribute : RpcAttribute
{
+ ///
+ /// When true, only the owner of the NetworkObject can invoke this ServerRpc
+ ///
public new bool RequireOwnership;
+ ///
+ /// Initializes a new instance of ServerRpcAttribute configured to target the server
+ ///
public ServerRpcAttribute() : base(SendTo.Server)
{
@@ -75,6 +115,9 @@ public ServerRpcAttribute() : base(SendTo.Server)
[AttributeUsage(AttributeTargets.Method)]
public class ClientRpcAttribute : RpcAttribute
{
+ ///
+ /// Initializes a new instance of ClientRpcAttribute configured to target all non-server clients
+ ///
public ClientRpcAttribute() : base(SendTo.NotServer)
{
diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/RpcParams.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/RpcParams.cs
index 7eb1a18009..b302e3f8f7 100644
--- a/com.unity.netcode.gameobjects/Runtime/Messaging/RpcParams.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Messaging/RpcParams.cs
@@ -3,22 +3,54 @@
namespace Unity.Netcode
{
+ ///
+ /// Specifies how RPC messages should be handled in terms of local execution timing
+ ///
public enum LocalDeferMode
{
+ ///
+ /// Uses the default behavior for RPC message handling
+ ///
Default,
+
+ ///
+ /// Defers the local execution of the RPC until the next network tick
+ ///
Defer,
+
+ ///
+ /// Executes the RPC immediately on the local client without waiting for network synchronization
+ ///
SendImmediate
}
+
///
- /// Generic RPC
+ /// Generic RPC. Defines parameters for sending Remote Procedure Calls (RPCs) in the network system
///
public struct RpcSendParams
{
+ ///
+ /// Specifies the target that will receive this RPC
+ ///
public BaseRpcTarget Target;
+ ///
+ /// Controls how the RPC is handled for local execution timing
+ ///
public LocalDeferMode LocalDeferMode;
+ ///
+ /// Implicitly converts a BaseRpcTarget to RpcSendParams
+ ///
+ /// The RPC target to convert
+ /// A new RpcSendParams instance with the specified target
public static implicit operator RpcSendParams(BaseRpcTarget target) => new RpcSendParams { Target = target };
+
+ ///
+ /// Implicitly converts a LocalDeferMode to RpcSendParams
+ ///
+ /// The defer mode to convert
+ /// A new RpcSendParams instance with the specified defer mode
public static implicit operator RpcSendParams(LocalDeferMode deferMode) => new RpcSendParams { LocalDeferMode = deferMode };
}
@@ -51,9 +83,32 @@ public struct RpcParams
///
public RpcReceiveParams Receive;
+ ///
+ /// Implicitly converts RpcSendParams to RpcParams
+ ///
+ /// The send parameters to convert
+ /// A new RpcParams instance with the specified send parameters
public static implicit operator RpcParams(RpcSendParams send) => new RpcParams { Send = send };
+
+ ///
+ /// Implicitly converts a BaseRpcTarget to RpcParams
+ ///
+ /// The RPC target to convert
+ /// A new RpcParams instance with the specified target in its send parameters
public static implicit operator RpcParams(BaseRpcTarget target) => new RpcParams { Send = new RpcSendParams { Target = target } };
+
+ ///
+ /// Implicitly converts a LocalDeferMode to RpcParams
+ ///
+ /// The defer mode to convert
+ /// A new RpcParams instance with the specified defer mode in its send parameters
public static implicit operator RpcParams(LocalDeferMode deferMode) => new RpcParams { Send = new RpcSendParams { LocalDeferMode = deferMode } };
+
+ ///
+ /// Implicitly converts RpcReceiveParams to RpcParams
+ ///
+ /// The receive parameters to convert
+ /// A new RpcParams instance with the specified receive parameters
public static implicit operator RpcParams(RpcReceiveParams receive) => new RpcParams { Receive = receive };
}
diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs
index 94625722e3..9100259a23 100644
--- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs
+++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs
@@ -4,10 +4,21 @@
namespace Unity.Netcode
{
-
+ ///
+ /// Defines how anticipated network variables handle authoritative updates that are older than the current anticipated state
+ ///
public enum StaleDataHandling
{
+ ///
+ /// Ignores authoritative updates that are older than the current anticipated state.
+ /// The anticipated value will not be replaced until a newer authoritative update is received.
+ ///
Ignore,
+
+ ///
+ /// Applies authoritative updates even if they are older than the current anticipated state.
+ /// This triggers reanticipation to calculate a new anticipated value based on the authoritative state.
+ ///
Reanticipate
}
@@ -85,6 +96,12 @@ public class AnticipatedNetworkVariable : NetworkVariableBase
#pragma warning restore IDE0001
public StaleDataHandling StaleDataHandling;
+ ///
+ /// Delegate for handling changes in the authoritative value
+ ///
+ /// The network variable that changed
+ /// The previous value before the change
+ /// The new value after the change
public delegate void OnAuthoritativeValueChangedDelegate(AnticipatedNetworkVariable variable, in T previousValue, in T newValue);
///
@@ -121,6 +138,9 @@ public void ResetAnticipation()
private AnticipatedObject m_AnticipatedObject;
+ ///
+ /// Initializes the network variable, setting up initial values and registering with the anticipation system
+ ///
public override void OnInitialize()
{
m_AuthoritativeValue.Initialize(m_NetworkBehaviour);
@@ -133,6 +153,10 @@ public override void OnInitialize()
}
}
+ ///
+ /// Checks if the current value has changed enough from its last synchronized value to warrant a new network update
+ ///
+ /// True if the value should be synchronized, false otherwise
public override bool ExceedsDirtinessThreshold()
{
return m_AuthoritativeValue.ExceedsDirtinessThreshold();
@@ -227,10 +251,19 @@ public T AuthoritativeValue
/// See , , , and so on
/// for examples.
///
+ /// The authoritative value to interpolate from
+ /// The anticipated value to interpolate to
+ /// The interpolation factor between 0 and 1
+ /// The interpolated value
public delegate T SmoothDelegate(T authoritativeValue, T anticipatedValue, float amount);
private SmoothDelegate m_SmoothDelegate = null;
+ ///
+ /// Initializes a new instance of the AnticipatedNetworkVariable class
+ ///
+ /// The initial value for the network variable. Defaults to the type's default value if not specified.
+ /// Determines how the variable handles authoritative updates that are older than the current anticipated state. Defaults to StaleDataHandling.Ignore.
public AnticipatedNetworkVariable(T value = default,
StaleDataHandling staleDataHandling = StaleDataHandling.Ignore)
: base()
@@ -242,6 +275,9 @@ public AnticipatedNetworkVariable(T value = default,
};
}
+ ///
+ /// Updates the smooth interpolation state if active
+ ///
public void Update()
{
if (m_CurrentSmoothTime < m_SmoothDuration)
@@ -253,6 +289,7 @@ public void Update()
}
}
+ ///
public override void Dispose()
{
if (m_IsDisposed)
@@ -302,6 +339,9 @@ public override void Dispose()
}
}
+ ///
+ /// Finalizer that ensures proper cleanup of network variable resources
+ ///
~AnticipatedNetworkVariable()
{
Dispose();
@@ -357,26 +397,31 @@ public void Smooth(in T from, in T to, float durationSeconds, SmoothDelegate how
m_HasSmoothValues = true;
}
+ ///
public override bool IsDirty()
{
return m_AuthoritativeValue.IsDirty();
}
+ ///
public override void ResetDirty()
{
m_AuthoritativeValue.ResetDirty();
}
+ ///
public override void WriteDelta(FastBufferWriter writer)
{
m_AuthoritativeValue.WriteDelta(writer);
}
+ ///
public override void WriteField(FastBufferWriter writer)
{
m_AuthoritativeValue.WriteField(writer);
}
+ ///
public override void ReadField(FastBufferReader reader)
{
m_AuthoritativeValue.ReadField(reader);
@@ -384,6 +429,7 @@ public override void ReadField(FastBufferReader reader)
NetworkVariableSerialization.Duplicate(m_AnticipatedValue, ref m_PreviousAnticipatedValue);
}
+ ///
public override void ReadDelta(FastBufferReader reader, bool keepDirtyDelta)
{
m_AuthoritativeValue.ReadDelta(reader, keepDirtyDelta);
diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs
index eaf06bbb67..2d00a4cf97 100644
--- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs
+++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs
@@ -49,6 +49,9 @@ public NetworkList(IEnumerable values = default,
}
}
+ ///
+ /// Finalizer that ensures proper cleanup of network list resources
+ ///
~NetworkList()
{
Dispose();
diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs
index 5df83215b1..cb5fe9e2b3 100644
--- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs
+++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs
@@ -22,10 +22,23 @@ public class NetworkVariable : NetworkVariableBase
///
public OnValueChangedDelegate OnValueChanged;
+ ///
+ /// Delegate that determines if the difference between two values exceeds a threshold for network synchronization
+ ///
+ /// The previous value to compare against
+ /// The new value to compare
+ /// True if the difference exceeds the threshold and should be synchronized, false otherwise
public delegate bool CheckExceedsDirtinessThresholdDelegate(in T previousValue, in T newValue);
+ ///
+ /// Delegate instance for checking if value changes exceed the dirtiness threshold
+ ///
public CheckExceedsDirtinessThresholdDelegate CheckExceedsDirtinessThreshold;
+ ///
+ /// Determines if the current value has changed enough from its previous value to warrant network synchronization
+ ///
+ /// True if the value should be synchronized, false otherwise
public override bool ExceedsDirtinessThreshold()
{
if (CheckExceedsDirtinessThreshold != null && m_HasPreviousValue)
@@ -36,6 +49,9 @@ public override bool ExceedsDirtinessThreshold()
return true;
}
+ ///
+ /// Initializes the NetworkVariable by setting up initial and previous values
+ ///
public override void OnInitialize()
{
base.OnInitialize();
@@ -90,7 +106,7 @@ public void Reset(T value = default)
// The introduction of standard .NET collections caused an issue with permissions since there is no way to detect changes in the
// collection without doing a full comparison. While this approach does consume more memory per collection instance, it is the
// lowest risk approach to resolving the issue where a client with no write permissions could make changes to a collection locally
- // which can cause a myriad of issues.
+ // which can cause a myriad of issues.
private protected T m_InternalOriginalValue;
private protected T m_PreviousValue;
@@ -135,11 +151,12 @@ public virtual T Value
/// Invoke this method to check if a collection's items are dirty.
/// The default behavior is to exit early if the is already dirty.
///
+ /// when true, this check will force a full item collection check even if the NetworkVariable is already dirty
+ /// True if the variable is dirty and needs synchronization, false if clean or client lacks write permissions
///
/// This is to be used as a way to check if a containing a managed collection has any changees to the collection items.
/// If you invoked this when a collection is dirty, it will not trigger the unless you set forceCheck param to true.
///
- /// when true, this check will force a full item collection check even if the NetworkVariable is already dirty
public bool CheckDirtyState(bool forceCheck = false)
{
var isDirty = base.IsDirty();
@@ -178,6 +195,7 @@ internal ref T RefValue()
return ref m_InternalValue;
}
+ ///
public override void Dispose()
{
if (m_IsDisposed)
@@ -208,6 +226,9 @@ public override void Dispose()
m_PreviousValue = default;
}
+ ///
+ /// Finalizer that ensures proper cleanup of resources
+ ///
~NetworkVariable()
{
Dispose();
@@ -320,7 +341,7 @@ public override void ReadDelta(FastBufferReader reader, bool keepDirtyDelta)
/// This should be always invoked (client & server) to assure the previous values are set
/// !! IMPORTANT !!
/// When a server forwards delta updates to connected clients, it needs to preserve the previous dirty value(s)
- /// until it is done serializing all valid NetworkVariable field deltas (relative to each client). This is invoked
+ /// until it is done serializing all valid NetworkVariable field deltas (relative to each client). This is invoked
/// after it is done forwarding the deltas at the end of the method.
///
internal override void PostDeltaRead()
diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableBase.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableBase.cs
index 377fadeee0..c68a887e86 100644
--- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableBase.cs
+++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableBase.cs
@@ -3,11 +3,20 @@
namespace Unity.Netcode
{
+ ///
+ /// Defines timing constraints for network variable updates
+ ///
public struct NetworkVariableUpdateTraits
{
+ ///
+ /// The minimum amount of time that must pass between sending updates. If this amount of time has not passed since the last update, dirtiness will be ignored.
+ ///
[Tooltip("The minimum amount of time that must pass between sending updates. If this amount of time has not passed since the last update, dirtiness will be ignored.")]
public float MinSecondsBetweenUpdates;
+ ///
+ /// The maximum amount of time that a variable can be dirty without sending an update. If this amount of time has passed since the last update, an update will be sent even if the dirtiness threshold has not been met.
+ ///
[Tooltip("The maximum amount of time that a variable can be dirty without sending an update. If this amount of time has passed since the last update, an update will be sent even if the dirtiness threshold has not been met.")]
public float MaxSecondsBetweenUpdates;
}
@@ -40,6 +49,10 @@ public abstract class NetworkVariableBase : IDisposable
// this NetworkVariableBase property instance will not update until the last session time used.
internal bool HasBeenInitialized { get; private set; }
+ ///
+ /// Gets the NetworkBehaviour instance associated with this network variable
+ ///
+ /// The NetworkBehaviour that owns this network variable
public NetworkBehaviour GetBehaviour()
{
return m_NetworkBehaviour;
@@ -240,6 +253,9 @@ internal void UpdateLastSentTime()
LastUpdateSent = m_NetworkBehaviour.NetworkManager.NetworkTimeSystem.LocalTime;
}
+ ///
+ /// Marks the associated NetworkBehaviour as dirty, indicating it needs synchronization
+ ///
protected void MarkNetworkBehaviourDirty()
{
if (m_NetworkBehaviour == null)
diff --git a/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs b/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs
index 7127279cda..eaa12089fe 100644
--- a/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs
@@ -28,6 +28,10 @@ public abstract class NetworkTransport : MonoBehaviour
///
/// Delegate for transport network events
///
+ /// The type of network event that occurred
+ /// The ID of the client associated with this event
+ /// The data payload received with this event
+ /// The time when this event was received
public delegate void TransportEventDelegate(NetworkEvent eventType, ulong clientId, ArraySegment payload, float receiveTime);
///
diff --git a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs
index 2665214c9f..957988563c 100644
--- a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs
@@ -384,6 +384,9 @@ public NetworkEndpoint ListenEndPoint
///
/// Returns true if the end point address is of type .
///
+ ///
+ /// True if the Address property contains a valid IPv6 address, false if it's empty or an IPv4 address
+ ///
public bool IsIpv6 => !string.IsNullOrEmpty(Address) && NetworkEndpoint.TryParse(Address, Port, out NetworkEndpoint _, NetworkFamily.Ipv6);
}
diff --git a/com.unity.netcode.gameobjects/TestHelpers/Runtime/NetcodeIntegrationTestHelpers.cs b/com.unity.netcode.gameobjects/TestHelpers/Runtime/NetcodeIntegrationTestHelpers.cs
index 3669c36f16..89319a0d3d 100644
--- a/com.unity.netcode.gameobjects/TestHelpers/Runtime/NetcodeIntegrationTestHelpers.cs
+++ b/com.unity.netcode.gameobjects/TestHelpers/Runtime/NetcodeIntegrationTestHelpers.cs
@@ -425,7 +425,7 @@ private static void SceneManagerValidationAndTestRunnerInitialization(NetworkMan
/// The Server NetworkManager
/// The Clients NetworkManager
/// called immediately after server is started and before client(s) are started
- ///
+ /// True if the network instances were started successfully, throws InvalidOperationException if already started
public static bool Start(bool host, NetworkManager server, NetworkManager[] clients, BeforeClientStartCallback callback = null)
{
if (s_IsStarted)
@@ -616,10 +616,10 @@ public static IEnumerator WaitForClientConnected(NetworkManager client, ResultWr
///
/// Similar to WaitForClientConnected, this waits for multiple clients to be connected.
///
- /// The clients to be connected
- /// The result. If null, it will automatically assert<
+ /// Array of clients to wait for
+ /// The result. If null, it will automatically assert
/// Maximum time in seconds to wait for the object to be found.
- ///
+ /// An IEnumerator that yields until all clients are connected or timeout is reached
public static IEnumerator WaitForClientsConnected(NetworkManager[] clients, ResultWrapper result = null, float timeout = DefaultTimeout)
{
// Make sure none are the host client
diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/Components/BufferDataValidationComponent.cs b/com.unity.netcode.gameobjects/Tests/Runtime/Components/BufferDataValidationComponent.cs
index 3912448423..8647f586d2 100644
--- a/com.unity.netcode.gameobjects/Tests/Runtime/Components/BufferDataValidationComponent.cs
+++ b/com.unity.netcode.gameobjects/Tests/Runtime/Components/BufferDataValidationComponent.cs
@@ -54,7 +54,7 @@ private void Start()
///
/// Returns back whether the test has completed the total number of iterations
///
- ///
+ /// True if the test has exceeded maximum buffer size or failed, false otherwise
public bool IsTestComplete()
{
if (m_CurrentBufferSize > MaximumBufferSize || TestFailed)
diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableBaseInitializesWhenPersisted.cs b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableBaseInitializesWhenPersisted.cs
index 2a9a1b052e..6996cb70f4 100644
--- a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableBaseInitializesWhenPersisted.cs
+++ b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableBaseInitializesWhenPersisted.cs
@@ -334,6 +334,9 @@ public void Initialize(NetworkManager networkManager)
///
/// This validates that the instances persisted to the next test set and persisted
/// between network sessions
+ ///
+ /// The minimum number of times each instance should have been spawned
+ /// True if all instances meet the minimum spawn count requirement, false otherwise
public bool ValidateInstanceSpawnCount(int minCount)
{
// First pass we should have no instances
diff --git a/pvpExceptions.json b/pvpExceptions.json
index 6a7fc8d678..03a2cee707 100644
--- a/pvpExceptions.json
+++ b/pvpExceptions.json
@@ -10,104 +10,8 @@
"Failed to find a suitable OpenCL device, baking cannot use GPU lightmapper."
]
},
- "PVP-150-1": {
- "errors": [
- "Unity.Netcode.TestHelpers.Runtime.NetcodeIntegrationTestHelpers: bool Start(bool, NetworkManager, NetworkManager[], BeforeClientStartCallback): empty tag",
- "Unity.Netcode.TestHelpers.Runtime.NetcodeIntegrationTestHelpers: IEnumerator WaitForClientsConnected(NetworkManager[], ResultWrapper, float): XML is not well-formed: An identifier was expected",
- "Unity.Netcode.RuntimeTests.BufferDataValidationComponent: bool IsTestComplete(): empty tag",
- "Unity.Netcode.RuntimeTests.NetworkVariableBaseInitializesWhenPersisted.PrefabInstanceHandler: bool ValidateInstanceSpawnCount(int): XML is not well-formed: Expected an end tag for element 'summary'"
- ]
- },
"PVP-151-1": {
"errors": [
- "Unity.Netcode.NetworkConfig: Prefabs: undocumented",
- "Unity.Netcode.NetworkPrefab: bool Equals(NetworkPrefab): undocumented",
- "Unity.Netcode.NetworkPrefab: SourcePrefabGlobalObjectIdHash: undocumented",
- "Unity.Netcode.NetworkPrefab: TargetPrefabGlobalObjectIdHash: undocumented",
- "Unity.Netcode.NetworkPrefab: bool Validate(int): undocumented",
- "Unity.Netcode.NetworkPrefab: string ToString(): undocumented",
- "Unity.Netcode.NetworkPrefabs: Prefabs: undocumented",
- "Unity.Netcode.NetworkPrefabs: void Finalize(): undocumented",
- "Unity.Netcode.NetworkPrefabs: void Initialize(bool): missing ",
- "Unity.Netcode.NetworkPrefabs: bool Add(NetworkPrefab): missing ",
- "Unity.Netcode.NetworkPrefabs: bool Add(NetworkPrefab): missing ",
- "Unity.Netcode.NetworkPrefabs: void Remove(NetworkPrefab): missing ",
- "Unity.Netcode.NetworkPrefabs: void Remove(GameObject): missing ",
- "Unity.Netcode.ConnectionEventData: EventType: undocumented",
- "Unity.Netcode.RpcException: undocumented",
- "Unity.Netcode.RpcException: .ctor(string): undocumented",
- "Unity.Netcode.NetworkManager: void NetworkUpdate(NetworkUpdateStage): undocumented",
- "Unity.Netcode.NetworkManager.ReanticipateDelegate: undocumented",
- "Unity.Netcode.NetworkObject: NetworkBehaviour GetNetworkBehaviourAtOrderIndex(ushort): undocumented",
- "Unity.Netcode.NetworkObject.VisibilityDelegate: missing ",
- "Unity.Netcode.NetworkObject.SpawnDelegate: missing ",
- "Unity.Netcode.CustomMessagingManager.HandleNamedMessageDelegate: missing ",
- "Unity.Netcode.CustomMessagingManager.HandleNamedMessageDelegate: missing ",
- "Unity.Netcode.GenerateSerializationForGenericParameterAttribute: .ctor(int): undocumented",
- "Unity.Netcode.GenerateSerializationForTypeAttribute: .ctor(Type): undocumented",
- "Unity.Netcode.RpcAttribute: RequireOwnership: undocumented",
- "Unity.Netcode.RpcAttribute: DeferLocal: undocumented",
- "Unity.Netcode.RpcAttribute: AllowTargetOverride: undocumented",
- "Unity.Netcode.RpcAttribute: .ctor(SendTo): undocumented",
- "Unity.Netcode.RpcAttribute.RpcAttributeParams: undocumented",
- "Unity.Netcode.RpcAttribute.RpcAttributeParams: Delivery: undocumented",
- "Unity.Netcode.RpcAttribute.RpcAttributeParams: RequireOwnership: undocumented",
- "Unity.Netcode.RpcAttribute.RpcAttributeParams: DeferLocal: undocumented",
- "Unity.Netcode.RpcAttribute.RpcAttributeParams: AllowTargetOverride: undocumented",
- "Unity.Netcode.ServerRpcAttribute: RequireOwnership: undocumented",
- "Unity.Netcode.ServerRpcAttribute: .ctor(): undocumented",
- "Unity.Netcode.ClientRpcAttribute: .ctor(): undocumented",
- "Unity.Netcode.LocalDeferMode: undocumented",
- "Unity.Netcode.LocalDeferMode: Default: undocumented",
- "Unity.Netcode.LocalDeferMode: Defer: undocumented",
- "Unity.Netcode.LocalDeferMode: SendImmediate: undocumented",
- "Unity.Netcode.RpcSendParams: Target: undocumented",
- "Unity.Netcode.RpcSendParams: LocalDeferMode: undocumented",
- "Unity.Netcode.RpcSendParams: RpcSendParams op_Implicit(BaseRpcTarget): undocumented",
- "Unity.Netcode.RpcSendParams: RpcSendParams op_Implicit(LocalDeferMode): undocumented",
- "Unity.Netcode.RpcParams: RpcParams op_Implicit(RpcSendParams): undocumented",
- "Unity.Netcode.RpcParams: RpcParams op_Implicit(BaseRpcTarget): undocumented",
- "Unity.Netcode.RpcParams: RpcParams op_Implicit(LocalDeferMode): undocumented",
- "Unity.Netcode.RpcParams: RpcParams op_Implicit(RpcReceiveParams): undocumented",
- "Unity.Netcode.StaleDataHandling: undocumented",
- "Unity.Netcode.StaleDataHandling: Ignore: undocumented",
- "Unity.Netcode.StaleDataHandling: Reanticipate: undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: void OnInitialize(): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: bool ExceedsDirtinessThreshold(): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: .ctor(T, StaleDataHandling): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: void Update(): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: void Dispose(): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: void Finalize(): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: bool IsDirty(): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: void ResetDirty(): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: void WriteDelta(FastBufferWriter): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: void WriteField(FastBufferWriter): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: void ReadField(FastBufferReader): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable: void ReadDelta(FastBufferReader, bool): undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable.OnAuthoritativeValueChangedDelegate: undocumented",
- "Unity.Netcode.AnticipatedNetworkVariable.SmoothDelegate: missing ",
- "Unity.Netcode.AnticipatedNetworkVariable.SmoothDelegate: missing ",
- "Unity.Netcode.AnticipatedNetworkVariable.SmoothDelegate: missing ",
- "Unity.Netcode.AnticipatedNetworkVariable.SmoothDelegate: missing ",
- "Unity.Netcode.NetworkList: void Finalize(): undocumented",
- "Unity.Netcode.NetworkVariable: CheckExceedsDirtinessThreshold: undocumented",
- "Unity.Netcode.NetworkVariable: bool ExceedsDirtinessThreshold(): undocumented",
- "Unity.Netcode.NetworkVariable: void OnInitialize(): undocumented",
- "Unity.Netcode.NetworkVariable: bool CheckDirtyState(bool): missing ",
- "Unity.Netcode.NetworkVariable: void Dispose(): undocumented",
- "Unity.Netcode.NetworkVariable: void Finalize(): undocumented",
- "Unity.Netcode.NetworkVariable.CheckExceedsDirtinessThresholdDelegate: undocumented",
- "Unity.Netcode.NetworkVariableUpdateTraits: undocumented",
- "Unity.Netcode.NetworkVariableUpdateTraits: MinSecondsBetweenUpdates: undocumented",
- "Unity.Netcode.NetworkVariableUpdateTraits: MaxSecondsBetweenUpdates: undocumented",
- "Unity.Netcode.NetworkVariableBase: NetworkBehaviour GetBehaviour(): undocumented",
- "Unity.Netcode.NetworkVariableBase: void MarkNetworkBehaviourDirty(): undocumented",
- "Unity.Netcode.NetworkSceneManager: void SetClientSynchronizationMode(LoadSceneMode): XML is not well-formed: Expected an end tag for element 'summary'",
- "Unity.Netcode.NetworkTransport.TransportEventDelegate: missing ",
- "Unity.Netcode.NetworkTransport.TransportEventDelegate: missing ",
- "Unity.Netcode.NetworkTransport.TransportEventDelegate: missing ",
- "Unity.Netcode.NetworkTransport.TransportEventDelegate: missing ",
- "Unity.Netcode.Transports.UTP.UnityTransport.ConnectionAddressData: IsIpv6: undocumented",
"Unity.Netcode.TestHelpers.Runtime.ObjectNameIdentifier: undocumented",
"Unity.Netcode.TestHelpers.Runtime.ObjectNameIdentifier: void OnNetworkSpawn(): undocumented",
"Unity.Netcode.TestHelpers.Runtime.ObjectNameIdentifier: void RegisterAndLabelNetworkObject(): undocumented",