Skip to content

Commit 9aff85f

Browse files
fix: API Audit for missing XML documentation [MTT-3881] (#2026)
1 parent 1cabb7d commit 9aff85f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2660
-66
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1818
### Changed
1919

2020
- Updated `UnityTransport` dependency on `com.unity.transport` to 1.1.0. (#2025)
21-
- (API Breaking) `ConnectionApprovalCallback` is no longer an `event` and will not allow more than 1 handler registered at a time. Also, `ConnectionApprovalCallback` is now a `Func<>` taking `ConnectionApprovalRequest` in and returning `ConnectionApprovalResponse` back out (#1972)
21+
- (API Breaking) `ConnectionApprovalCallback` is no longer an `event` and will not allow more than 1 handler registered at a time. Also, `ConnectionApprovalCallback` is now an `Action<>` taking a `ConnectionApprovalRequest` and a `ConnectionApprovalResponse` that the client code must fill (#1972) (#2002)
2222

2323
### Removed
2424

com.unity.netcode.gameobjects/Components/Interpolator/BufferedLinearInterpolator.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Unity.Netcode
88
/// Solves for incoming values that are jittered
99
/// Partially solves for message loss. Unclamped lerping helps hide this, but not completely
1010
/// </summary>
11+
/// <typeparam name="T">The type of interpolated value</typeparam>
1112
public abstract class BufferedLinearInterpolator<T> where T : struct
1213
{
1314
internal float MaxInterpolationBound = 3.0f;
@@ -24,7 +25,7 @@ public BufferedItem(T item, double timeSent)
2425
}
2526

2627
/// <summary>
27-
/// Theres two factors affecting interpolation: buffering (set in NetworkManagers NetworkTimeSystem) and interpolation time, which is the amount of time itll take to reach the target. This is to affect the second one.
28+
/// There's two factors affecting interpolation: buffering (set in NetworkManager's NetworkTimeSystem) and interpolation time, which is the amount of time it'll take to reach the target. This is to affect the second one.
2829
/// </summary>
2930
public float MaximumInterpolationTime = 0.1f;
3031

@@ -73,7 +74,7 @@ public BufferedItem(T item, double timeSent)
7374
private bool InvalidState => m_Buffer.Count == 0 && m_LifetimeConsumedCount == 0;
7475

7576
/// <summary>
76-
/// Resets Interpolator to initial state
77+
/// Resets interpolator to initial state
7778
/// </summary>
7879
public void Clear()
7980
{
@@ -85,6 +86,8 @@ public void Clear()
8586
/// <summary>
8687
/// Teleports current interpolation value to targetValue.
8788
/// </summary>
89+
/// <param name="targetValue">The target value to teleport instantly</param>
90+
/// <param name="serverTime">The current server time</param>
8891
public void ResetTo(T targetValue, double serverTime)
8992
{
9093
m_LifetimeConsumedCount = 1;
@@ -159,6 +162,7 @@ private void TryConsumeFromBuffer(double renderTime, double serverTime)
159162
/// </summary>
160163
/// <param name="deltaTime">time since call</param>
161164
/// <param name="serverTime">current server time</param>
165+
/// <returns>The newly interpolated value of type 'T'</returns>
162166
public T Update(float deltaTime, NetworkTime serverTime)
163167
{
164168
return Update(deltaTime, serverTime.TimeTicksAgo(1).Time, serverTime.Time);
@@ -170,6 +174,7 @@ public T Update(float deltaTime, NetworkTime serverTime)
170174
/// <param name="deltaTime">time since last call</param>
171175
/// <param name="renderTime">our current time</param>
172176
/// <param name="serverTime">current server time</param>
177+
/// <returns>The newly interpolated value of type 'T'</returns>
173178
public T Update(float deltaTime, double renderTime, double serverTime)
174179
{
175180
TryConsumeFromBuffer(renderTime, serverTime);
@@ -222,6 +227,8 @@ public T Update(float deltaTime, double renderTime, double serverTime)
222227
/// <summary>
223228
/// Add measurements to be used during interpolation. These will be buffered before being made available to be displayed as "latest value".
224229
/// </summary>
230+
/// <param name="newMeasurement">The new measurement value to use</param>
231+
/// <param name="sentTime">The time to record for measurement</param>
225232
public void AddMeasurement(T newMeasurement, double sentTime)
226233
{
227234
m_NbItemsReceivedThisFrame++;
@@ -251,6 +258,7 @@ public void AddMeasurement(T newMeasurement, double sentTime)
251258
/// <summary>
252259
/// Gets latest value from the interpolator. This is updated every update as time goes by.
253260
/// </summary>
261+
/// <returns>The current interpolated value of type 'T'</returns>
254262
public T GetInterpolatedValue()
255263
{
256264
return m_CurrentInterpValue;
@@ -259,33 +267,54 @@ public T GetInterpolatedValue()
259267
/// <summary>
260268
/// Method to override and adapted to the generic type. This assumes interpolation for that value will be clamped.
261269
/// </summary>
270+
/// <param name="start">The start value (min)</param>
271+
/// <param name="end">The end value (max)</param>
272+
/// <param name="time">The time value used to interpolate between start and end values (pos)</param>
273+
/// <returns>The interpolated value</returns>
262274
protected abstract T Interpolate(T start, T end, float time);
275+
263276
/// <summary>
264277
/// Method to override and adapted to the generic type. This assumes interpolation for that value will not be clamped.
265278
/// </summary>
279+
/// <param name="start">The start value (min)</param>
280+
/// <param name="end">The end value (max)</param>
281+
/// <param name="time">The time value used to interpolate between start and end values (pos)</param>
282+
/// <returns>The interpolated value</returns>
266283
protected abstract T InterpolateUnclamped(T start, T end, float time);
267284
}
268285

286+
/// <inheritdoc />
287+
/// <remarks>
288+
/// This is a buffered linear interpolator for a <see cref="float"/> type value
289+
/// </remarks>
269290
public class BufferedLinearInterpolatorFloat : BufferedLinearInterpolator<float>
270291
{
292+
/// <inheritdoc />
271293
protected override float InterpolateUnclamped(float start, float end, float time)
272294
{
273295
return Mathf.LerpUnclamped(start, end, time);
274296
}
275297

298+
/// <inheritdoc />
276299
protected override float Interpolate(float start, float end, float time)
277300
{
278301
return Mathf.Lerp(start, end, time);
279302
}
280303
}
281304

305+
/// <inheritdoc />
306+
/// <remarks>
307+
/// This is a buffered linear interpolator for a <see cref="Quaternion"/> type value
308+
/// </remarks>
282309
public class BufferedLinearInterpolatorQuaternion : BufferedLinearInterpolator<Quaternion>
283310
{
311+
/// <inheritdoc />
284312
protected override Quaternion InterpolateUnclamped(Quaternion start, Quaternion end, float time)
285313
{
286314
return Quaternion.SlerpUnclamped(start, end, time);
287315
}
288316

317+
/// <inheritdoc />
289318
protected override Quaternion Interpolate(Quaternion start, Quaternion end, float time)
290319
{
291320
return Quaternion.SlerpUnclamped(start, end, time);

com.unity.netcode.gameobjects/Components/NetworkAnimator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ private void FlushMessages()
3737
m_SendTriggerUpdates.Clear();
3838
}
3939

40+
/// <inheritdoc />
4041
public void NetworkUpdate(NetworkUpdateStage updateStage)
4142
{
4243
switch (updateStage)

com.unity.netcode.gameobjects/Components/NetworkTransform.cs

Lines changed: 112 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,46 @@
55
namespace Unity.Netcode.Components
66
{
77
/// <summary>
8-
/// A component for syncing transforms
8+
/// A component for syncing transforms.
99
/// NetworkTransform will read the underlying transform and replicate it to clients.
10-
/// The replicated value will be automatically be interpolated (if active) and applied to the underlying GameObject's transform
10+
/// The replicated value will be automatically be interpolated (if active) and applied to the underlying GameObject's transform.
1111
/// </summary>
1212
[DisallowMultipleComponent]
1313
[AddComponentMenu("Netcode/" + nameof(NetworkTransform))]
1414
[DefaultExecutionOrder(100000)] // this is needed to catch the update time after the transform was updated by user scripts
1515
public class NetworkTransform : NetworkBehaviour
1616
{
17+
/// <summary>
18+
/// The default position change threshold value.
19+
/// Any changes above this threshold will be replicated.
20+
/// </summary>
1721
public const float PositionThresholdDefault = 0.001f;
22+
23+
/// <summary>
24+
/// The default rotation angle change threshold value.
25+
/// Any changes above this threshold will be replicated.
26+
/// </summary>
1827
public const float RotAngleThresholdDefault = 0.01f;
28+
29+
/// <summary>
30+
/// The default scale change threshold value.
31+
/// Any changes above this threshold will be replicated.
32+
/// </summary>
1933
public const float ScaleThresholdDefault = 0.01f;
2034

35+
/// <summary>
36+
/// The handler delegate type that takes client requested changes and returns resulting changes handled by the server.
37+
/// </summary>
38+
/// <param name="pos">The position requested by the client.</param>
39+
/// <param name="rot">The rotation requested by the client.</param>
40+
/// <param name="scale">The scale requested by the client.</param>
41+
/// <returns>The resulting position, rotation and scale changes after handling.</returns>
2142
public delegate (Vector3 pos, Quaternion rotOut, Vector3 scale) OnClientRequestChangeDelegate(Vector3 pos, Quaternion rot, Vector3 scale);
43+
44+
/// <summary>
45+
/// The handler that gets invoked when server receives a change from a client.
46+
/// This handler would be useful for server to modify pos/rot/scale before applying client's request.
47+
/// </summary>
2248
public OnClientRequestChangeDelegate OnClientRequestChange;
2349

2450
internal struct NetworkTransformState : INetworkSerializable
@@ -244,15 +270,62 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
244270
}
245271
}
246272

247-
public bool SyncPositionX = true, SyncPositionY = true, SyncPositionZ = true;
248-
public bool SyncRotAngleX = true, SyncRotAngleY = true, SyncRotAngleZ = true;
249-
public bool SyncScaleX = true, SyncScaleY = true, SyncScaleZ = true;
273+
/// <summary>
274+
/// Whether or not x component of position will be replicated
275+
/// </summary>
276+
public bool SyncPositionX = true;
277+
/// <summary>
278+
/// Whether or not y component of position will be replicated
279+
/// </summary>
280+
public bool SyncPositionY = true;
281+
/// <summary>
282+
/// Whether or not z component of position will be replicated
283+
/// </summary>
284+
public bool SyncPositionZ = true;
285+
/// <summary>
286+
/// Whether or not x component of rotation will be replicated
287+
/// </summary>
288+
public bool SyncRotAngleX = true;
289+
/// <summary>
290+
/// Whether or not y component of rotation will be replicated
291+
/// </summary>
292+
public bool SyncRotAngleY = true;
293+
/// <summary>
294+
/// Whether or not z component of rotation will be replicated
295+
/// </summary>
296+
public bool SyncRotAngleZ = true;
297+
/// <summary>
298+
/// Whether or not x component of scale will be replicated
299+
/// </summary>
300+
public bool SyncScaleX = true;
301+
/// <summary>
302+
/// Whether or not y component of scale will be replicated
303+
/// </summary>
304+
public bool SyncScaleY = true;
305+
/// <summary>
306+
/// Whether or not z component of scale will be replicated
307+
/// </summary>
308+
public bool SyncScaleZ = true;
250309

310+
/// <summary>
311+
/// The current position threshold value
312+
/// Any changes to the position that exceeds the current threshold value will be replicated
313+
/// </summary>
251314
public float PositionThreshold = PositionThresholdDefault;
252315

316+
/// <summary>
317+
/// The current rotation threshold value
318+
/// Any changes to the rotation that exceeds the current threshold value will be replicated
319+
/// Minimum Value: 0.001
320+
/// Maximum Value: 360.0
321+
/// </summary>
253322
[Range(0.001f, 360.0f)]
254323
public float RotAngleThreshold = RotAngleThresholdDefault;
255324

325+
/// <summary>
326+
/// The current scale threshold value
327+
/// Any changes to the scale that exceeds the current threshold value will be replicated
328+
/// </summary>
256329
public float ScaleThreshold = ScaleThresholdDefault;
257330

258331
/// <summary>
@@ -265,6 +338,10 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
265338
public bool InLocalSpace = false;
266339
private bool m_LastInterpolateLocal = false; // was the last frame local
267340

341+
/// <summary>
342+
/// When enabled (default) interpolation is applied and when disabled no interpolation is applied
343+
/// Note: can be changed during runtime.
344+
/// </summary>
268345
public bool Interpolate = true;
269346
private bool m_LastInterpolate = true; // was the last frame interpolated
270347

@@ -276,7 +353,17 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
276353
/// </summary>
277354
// This is public to make sure that users don't depend on this IsClient && IsOwner check in their code. If this logic changes in the future, we can make it invisible here
278355
public bool CanCommitToTransform { get; protected set; }
356+
357+
/// <summary>
358+
/// Internally used by <see cref="NetworkTransform"/> to keep track of whether this <see cref="NetworkBehaviour"/> derived class instance
359+
/// was instantiated on the server side or not.
360+
/// </summary>
279361
protected bool m_CachedIsServer;
362+
363+
/// <summary>
364+
/// Internally used by <see cref="NetworkTransform"/> to keep track of the <see cref="NetworkManager"/> instance assigned to this
365+
/// this <see cref="NetworkBehaviour"/> derived class instance.
366+
/// </summary>
280367
protected NetworkManager m_CachedNetworkManager;
281368

282369
private readonly NetworkVariable<NetworkTransformState> m_ReplicatedNetworkState = new NetworkVariable<NetworkTransformState>(new NetworkTransformState());
@@ -716,6 +803,13 @@ private void OnNetworkStateChanged(NetworkTransformState oldState, NetworkTransf
716803
}
717804
}
718805

806+
/// <summary>
807+
/// Will set the maximum interpolation boundary for the interpolators of this <see cref="NetworkTransform"/> instance.
808+
/// This value roughly translates to the maximum value of 't' in <see cref="Mathf.Lerp(float, float, float)"/> and
809+
/// <see cref="Mathf.LerpUnclamped(float, float, float)"/> for all transform elements being monitored by
810+
/// <see cref="NetworkTransform"/> (i.e. Position, Rotation, and Scale)
811+
/// </summary>
812+
/// <param name="maxInterpolationBound">Maximum time boundary that can be used in a frame when interpolating between two values</param>
719813
public void SetMaxInterpolationBound(float maxInterpolationBound)
720814
{
721815
m_PositionXInterpolator.MaxInterpolationBound = maxInterpolationBound;
@@ -750,6 +844,8 @@ private void Awake()
750844
}
751845
}
752846

847+
848+
/// <inheritdoc/>
753849
public override void OnNetworkSpawn()
754850
{
755851
// must set up m_Transform in OnNetworkSpawn because it's possible an object spawns but is disabled
@@ -773,16 +869,19 @@ public override void OnNetworkSpawn()
773869
Initialize();
774870
}
775871

872+
/// <inheritdoc/>
776873
public override void OnNetworkDespawn()
777874
{
778875
m_ReplicatedNetworkState.OnValueChanged -= OnNetworkStateChanged;
779876
}
780877

878+
/// <inheritdoc/>
781879
public override void OnGainedOwnership()
782880
{
783881
Initialize();
784882
}
785883

884+
/// <inheritdoc/>
786885
public override void OnLostOwnership()
787886
{
788887
Initialize();
@@ -850,8 +949,7 @@ public void SetState(Vector3? posIn = null, Quaternion? rotIn = null, Vector3? s
850949
[ServerRpc]
851950
private void SetStateServerRpc(Vector3 pos, Quaternion rot, Vector3 scale, bool shouldTeleport)
852951
{
853-
// server has received this RPC request to move change transform. Give the server a chance to modify or
854-
// even reject the move
952+
// server has received this RPC request to move change transform. give the server a chance to modify or even reject the move
855953
if (OnClientRequestChange != null)
856954
{
857955
(pos, rot, scale) = OnClientRequestChange(pos, rot, scale);
@@ -862,8 +960,9 @@ private void SetStateServerRpc(Vector3 pos, Quaternion rot, Vector3 scale, bool
862960
m_LocalAuthoritativeNetworkState.IsTeleportingNextFrame = shouldTeleport;
863961
}
864962

865-
// todo this is currently in update, to be able to catch any transform changes. A FixedUpdate mode could be added to be less intense, but it'd be
963+
// todo: this is currently in update, to be able to catch any transform changes. A FixedUpdate mode could be added to be less intense, but it'd be
866964
// conditional to users only making transform update changes in FixedUpdate.
965+
/// <inheritdoc/>
867966
protected virtual void Update()
868967
{
869968
if (!IsSpawned)
@@ -921,6 +1020,10 @@ protected virtual void Update()
9211020
/// <summary>
9221021
/// Teleports the transform to the given values without interpolating
9231022
/// </summary>
1023+
/// <param name="newPosition"></param> new position to move to.
1024+
/// <param name="newRotation"></param> new rotation to rotate to.
1025+
/// <param name="newScale">new scale to scale to.</param>
1026+
/// <exception cref="Exception"></exception>
9241027
public void Teleport(Vector3 newPosition, Quaternion newRotation, Vector3 newScale)
9251028
{
9261029
if (!CanCommitToTransform)
@@ -945,6 +1048,7 @@ public void Teleport(Vector3 newPosition, Quaternion newRotation, Vector3 newSca
9451048
/// <summary>
9461049
/// Override this method and return false to switch to owner authoritative mode
9471050
/// </summary>
1051+
/// <returns>(<see cref="true"/> or <see cref="false"/>) where when false it runs as owner-client authoritative</returns>
9481052
protected virtual bool OnIsServerAuthoritative()
9491053
{
9501054
return true;

com.unity.netcode.gameobjects/Editor/NetworkBehaviourEditor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ private void RenderNetworkVariableValueType<T>(int index) where T : unmanaged
151151
}
152152
}
153153

154+
155+
/// <inheritdoc/>
154156
public override void OnInspectorGUI()
155157
{
156158
if (!m_Initialized)
@@ -230,6 +232,11 @@ private void OnEnable()
230232

231233
internal const string AutoAddNetworkObjectIfNoneExists = "AutoAdd-NetworkObject-When-None-Exist";
232234

235+
/// <summary>
236+
/// Recursively finds the root parent of a <see cref="Transform"/>
237+
/// </summary>
238+
/// <param name="transform">The current <see cref="Transform"/> we are inspecting for a parent</param>
239+
/// <returns>the root parent for the first <see cref="Transform"/> passed into the method</returns>
233240
public static Transform GetRootParentTransform(Transform transform)
234241
{
235242
if (transform.parent == null || transform.parent == transform)
@@ -244,6 +251,8 @@ public static Transform GetRootParentTransform(Transform transform)
244251
/// does not already have a NetworkObject component. If not it will notify
245252
/// the user that NetworkBehaviours require a NetworkObject.
246253
/// </summary>
254+
/// <param name="gameObject"><see cref="GameObject"/> to start checking for a <see cref="NetworkObject"/></param>
255+
/// <param name="networkObjectRemoved">used internally</param>
247256
public static void CheckForNetworkObject(GameObject gameObject, bool networkObjectRemoved = false)
248257
{
249258
// If there are no NetworkBehaviours or no gameObject, then exit early

0 commit comments

Comments
 (0)