Skip to content

Commit 8b48148

Browse files
Merge develop into fix/transportId-to-clientId
2 parents c9a8ca6 + bd3e5a2 commit 8b48148

22 files changed

+414
-240
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public class NetworkConfig
3131
[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.")]
3232
public GameObject PlayerPrefab;
3333

34+
/// <summary>
35+
/// The collection of network prefabs available for spawning across the network.
36+
/// </summary>
3437
[SerializeField]
3538
public NetworkPrefabs Prefabs = new NetworkPrefabs();
3639

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: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ public class NetworkPrefabs
3434
/// This is used for the legacy way of spawning NetworkPrefabs with an override when manually instantiating and spawning.
3535
/// To handle multiple source NetworkPrefab overrides that all point to the same target NetworkPrefab use
3636
/// <see cref="NetworkSpawnManager.InstantiateAndSpawn(NetworkObject, ulong, bool, bool, bool, Vector3, Quaternion)"/>
37-
/// or <see cref="NetworkObject.InstantiateAndSpawn(NetworkManager, ulong, bool, bool, bool, Vector3, Quaternion)"/>
37+
/// or <see cref="NetworkObject.InstantiateAndSpawn(NetworkManager, ulong, bool, bool, bool, Vector3, Quaternion)"/>.
3838
/// </summary>
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,14 +65,16 @@ private void RemoveTriggeredByNetworkPrefabList(NetworkPrefab networkPrefab)
6265
m_Prefabs.Remove(networkPrefab);
6366
}
6467

68+
/// <summary>
69+
/// Destructor that cleans up network prefab resources.
70+
/// </summary>
6571
~NetworkPrefabs()
6672
{
6773
Shutdown();
6874
}
6975

7076
/// <summary>
71-
/// Deregister from add and remove events
72-
/// Clear the list
77+
/// Deregister from add and remove events and clear the events.
7378
/// </summary>
7479
internal void Shutdown()
7580
{
@@ -84,6 +89,7 @@ internal void Shutdown()
8489
/// Processes the <see cref="NetworkPrefabsList"/> if one is present for use during runtime execution,
8590
/// else processes <see cref="Prefabs"/>.
8691
/// </summary>
92+
/// <param name="warnInvalid">When true, logs warnings about invalid prefabs that are removed during initialization.</param>
8793
public void Initialize(bool warnInvalid = true)
8894
{
8995
m_Prefabs.Clear();
@@ -154,11 +160,12 @@ public void Initialize(bool warnInvalid = true)
154160
}
155161

156162
/// <summary>
157-
/// Add a new NetworkPrefab instance to the list
163+
/// Add a new NetworkPrefab instance to the list.
158164
/// </summary>
165+
/// <param name="networkPrefab">The <see cref="NetworkPrefab"/> to add.</param>
166+
/// <returns>True if the prefab was successfully added, false if it was invalid or already registered</returns>
159167
/// <remarks>
160-
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
161-
///
168+
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.<br />
162169
/// Any modifications made here are not persisted. Permanent configuration changes should be done
163170
/// through the <see cref="NetworkPrefabsList"/> scriptable object property.
164171
/// </remarks>
@@ -175,11 +182,11 @@ public bool Add(NetworkPrefab networkPrefab)
175182
}
176183

177184
/// <summary>
178-
/// Remove a NetworkPrefab instance from the list
185+
/// Remove a NetworkPrefab instance from the list.
179186
/// </summary>
187+
/// <param name="prefab">The <see cref="NetworkPrefab"/> to remove.</param>
180188
/// <remarks>
181-
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
182-
///
189+
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.<br />
183190
/// Any modifications made here are not persisted. Permanent configuration changes should be done
184191
/// through the <see cref="NetworkPrefabsList"/> scriptable object property.
185192
/// </remarks>
@@ -197,11 +204,11 @@ public void Remove(NetworkPrefab prefab)
197204
}
198205

199206
/// <summary>
200-
/// Remove a NetworkPrefab instance with matching <see cref="NetworkPrefab.Prefab"/> from the list
207+
/// Remove a NetworkPrefab instance with matching <see cref="NetworkPrefab.Prefab"/> from the list.
201208
/// </summary>
209+
/// <param name="prefab">The <see cref="GameObject"/> to match against for removal.</param>
202210
/// <remarks>
203-
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
204-
///
211+
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.<br />
205212
/// Any modifications made here are not persisted. Permanent configuration changes should be done
206213
/// through the <see cref="NetworkPrefabsList"/> scriptable object property.
207214
/// </remarks>
@@ -232,10 +239,10 @@ public void Remove(GameObject prefab)
232239
}
233240

234241
/// <summary>
235-
/// Check if the given GameObject is present as a prefab within the list
242+
/// Check if the given GameObject is present as a prefab within the list.
236243
/// </summary>
237-
/// <param name="prefab">The prefab to check</param>
238-
/// <returns>Whether or not the prefab exists</returns>
244+
/// <param name="prefab">The prefab to check.</param>
245+
/// <returns>True if the prefab exists or false if it does not.</returns>
239246
public bool Contains(GameObject prefab)
240247
{
241248
for (int i = 0; i < m_Prefabs.Count; i++)
@@ -251,10 +258,10 @@ public bool Contains(GameObject prefab)
251258
}
252259

253260
/// <summary>
254-
/// Check if the given NetworkPrefab is present within the list
261+
/// Check if the given NetworkPrefab is present within the list.
255262
/// </summary>
256-
/// <param name="prefab">The prefab to check</param>
257-
/// <returns>Whether or not the prefab exists</returns>
263+
/// <param name="prefab">The prefab to check.</param>
264+
/// <returns>True if the prefab exists or false if it does not.</returns>
258265
public bool Contains(NetworkPrefab prefab)
259266
{
260267
for (int i = 0; i < m_Prefabs.Count; i++)
@@ -269,7 +276,7 @@ public bool Contains(NetworkPrefab prefab)
269276
}
270277

271278
/// <summary>
272-
/// Configures <see cref="NetworkPrefabOverrideLinks"/> for the given <see cref="NetworkPrefab"/>
279+
/// Configures <see cref="NetworkPrefabOverrideLinks"/> for the given <see cref="NetworkPrefab"/>.
273280
/// </summary>
274281
private bool AddPrefabRegistration(NetworkPrefab networkPrefab)
275282
{

0 commit comments

Comments
 (0)