Skip to content

Commit cdc7560

Browse files
committed
NetworkVariable corrections and added inheritdocs when API is override
1 parent 0917354 commit cdc7560

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,7 @@ public void Update()
284284
}
285285
}
286286

287-
/// <summary>
288-
/// Releases all resources used by this network variable
289-
/// </summary>
287+
/// <inheritdoc/>
290288
public override void Dispose()
291289
{
292290
if (m_IsDisposed)
@@ -391,57 +389,39 @@ public void Smooth(in T from, in T to, float durationSeconds, SmoothDelegate how
391389
m_HasSmoothValues = true;
392390
}
393391

394-
/// <summary>
395-
/// Checks if the variable has been modified since the last network synchronization
396-
/// </summary>
397-
/// <returns>True if the variable needs to be synchronized, false otherwise</returns>
392+
/// <inheritdoc/>
398393
public override bool IsDirty()
399394
{
400395
return m_AuthoritativeValue.IsDirty();
401396
}
402397

403-
/// <summary>
404-
/// Resets the dirty state after network synchronization
405-
/// </summary>
398+
/// <inheritdoc/>
406399
public override void ResetDirty()
407400
{
408401
m_AuthoritativeValue.ResetDirty();
409402
}
410403

411-
/// <summary>
412-
/// Writes only the changes in the variable's value to the network stream
413-
/// </summary>
414-
/// <param name="writer">Buffer to write the delta to</param>
404+
/// <inheritdoc/>
415405
public override void WriteDelta(FastBufferWriter writer)
416406
{
417407
m_AuthoritativeValue.WriteDelta(writer);
418408
}
419409

420-
/// <summary>
421-
/// Writes the complete state of the variable to the network stream
422-
/// </summary>
423-
/// <param name="writer">Buffer to write the field to</param>
410+
/// <inheritdoc/>
424411
public override void WriteField(FastBufferWriter writer)
425412
{
426413
m_AuthoritativeValue.WriteField(writer);
427414
}
428415

429-
/// <summary>
430-
/// Reads the complete state of the variable from the network stream
431-
/// </summary>
432-
/// <param name="reader">Buffer to read the field from</param>
416+
/// <inheritdoc/>
433417
public override void ReadField(FastBufferReader reader)
434418
{
435419
m_AuthoritativeValue.ReadField(reader);
436420
NetworkVariableSerialization<T>.Duplicate(m_AuthoritativeValue.Value, ref m_AnticipatedValue);
437421
NetworkVariableSerialization<T>.Duplicate(m_AnticipatedValue, ref m_PreviousAnticipatedValue);
438422
}
439423

440-
/// <summary>
441-
/// Reads changes in the variable's value from the network stream
442-
/// </summary>
443-
/// <param name="reader">Buffer to read the delta from</param>
444-
/// <param name="keepDirtyDelta">Whether to maintain the dirty state after reading</param>
424+
/// <inheritdoc/>
445425
public override void ReadDelta(FastBufferReader reader, bool keepDirtyDelta)
446426
{
447427
m_AuthoritativeValue.ReadDelta(reader, keepDirtyDelta);

com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,23 @@ public class NetworkVariable<T> : NetworkVariableBase
2222
/// </summary>
2323
public OnValueChangedDelegate OnValueChanged;
2424

25+
/// <summary>
26+
/// Delegate that determines if the difference between two values exceeds a threshold for network synchronization
27+
/// </summary>
28+
/// <param name="previousValue">The previous value to compare against</param>
29+
/// <param name="newValue">The new value to compare</param>
30+
/// <returns>True if the difference exceeds the threshold and should be synchronized, false otherwise</returns>
2531
public delegate bool CheckExceedsDirtinessThresholdDelegate(in T previousValue, in T newValue);
2632

33+
/// <summary>
34+
/// Delegate instance for checking if value changes exceed the dirtiness threshold
35+
/// </summary>
2736
public CheckExceedsDirtinessThresholdDelegate CheckExceedsDirtinessThreshold;
2837

38+
/// <summary>
39+
/// Determines if the current value has changed enough from its previous value to warrant network synchronization
40+
/// </summary>
41+
/// <returns>True if the value should be synchronized, false otherwise</returns>
2942
public override bool ExceedsDirtinessThreshold()
3043
{
3144
if (CheckExceedsDirtinessThreshold != null && m_HasPreviousValue)
@@ -36,6 +49,9 @@ public override bool ExceedsDirtinessThreshold()
3649
return true;
3750
}
3851

52+
/// <summary>
53+
/// Initializes the NetworkVariable by setting up initial and previous values
54+
/// </summary>
3955
public override void OnInitialize()
4056
{
4157
base.OnInitialize();
@@ -171,6 +187,7 @@ internal ref T RefValue()
171187
return ref m_InternalValue;
172188
}
173189

190+
/// <inheritdoc/>
174191
public override void Dispose()
175192
{
176193
if (m_IsDisposed)
@@ -201,6 +218,9 @@ public override void Dispose()
201218
m_PreviousValue = default;
202219
}
203220

221+
/// <summary>
222+
/// Finalizer that ensures proper cleanup of resources
223+
/// </summary>
204224
~NetworkVariable()
205225
{
206226
Dispose();

0 commit comments

Comments
 (0)