Skip to content

Commit 6843336

Browse files
committed
NetworkPrefab and NetworkPrefabs corrections
1 parent 69590ad commit 6843336

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

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+
/// <returns>The hash value identifying the source prefab</returns>
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+
/// <returns>The hash value identifying the target prefab, or 0 if no override is set</returns>
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: 8 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]
@@ -84,6 +87,7 @@ internal void Shutdown()
8487
/// Processes the <see cref="NetworkPrefabsList"/> if one is present for use during runtime execution,
8588
/// else processes <see cref="Prefabs"/>.
8689
/// </summary>
90+
/// /// <param name="warnInvalid">When true, logs warnings about invalid prefabs that are removed during initialization</param>
8791
public void Initialize(bool warnInvalid = true)
8892
{
8993
m_Prefabs.Clear();
@@ -156,6 +160,8 @@ public void Initialize(bool warnInvalid = true)
156160
/// <summary>
157161
/// Add a new NetworkPrefab instance to the list
158162
/// </summary>
163+
/// <param name="networkPrefab">The NetworkPrefab to add</param>
164+
/// <returns>True if the prefab was successfully added, false if it was invalid or already registered</returns>
159165
/// <remarks>
160166
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
161167
///
@@ -177,6 +183,7 @@ public bool Add(NetworkPrefab networkPrefab)
177183
/// <summary>
178184
/// Remove a NetworkPrefab instance from the list
179185
/// </summary>
186+
/// <param name="prefab">The NetworkPrefab to remove</param>
180187
/// <remarks>
181188
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
182189
///
@@ -199,6 +206,7 @@ public void Remove(NetworkPrefab prefab)
199206
/// <summary>
200207
/// Remove a NetworkPrefab instance with matching <see cref="NetworkPrefab.Prefab"/> from the list
201208
/// </summary>
209+
/// <param name="prefab">The GameObject to match against for removal</param>
202210
/// <remarks>
203211
/// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
204212
///

pvpExceptions.json

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,7 @@
2121
"Unity.Netcode.NetworkConfig: Prefabs: undocumented",
2222
"Unity.Netcode.NetworkConfig: NetworkTopology: undocumented",
2323
"Unity.Netcode.NetworkConfig: UseCMBService: undocumented",
24-
"Unity.Netcode.NetworkConfig: AutoSpawnPlayerPrefabClientSide: undocumented",
25-
"Unity.Netcode.NetworkPrefab: bool Equals(NetworkPrefab): undocumented",
26-
"Unity.Netcode.NetworkPrefab: SourcePrefabGlobalObjectIdHash: undocumented",
27-
"Unity.Netcode.NetworkPrefab: TargetPrefabGlobalObjectIdHash: undocumented",
28-
"Unity.Netcode.NetworkPrefab: bool Validate(int): undocumented",
29-
"Unity.Netcode.NetworkPrefab: string ToString(): undocumented",
30-
"Unity.Netcode.NetworkPrefabs: Prefabs: undocumented",
31-
"Unity.Netcode.NetworkPrefabs: void Finalize(): undocumented",
32-
"Unity.Netcode.NetworkPrefabs: void Initialize(bool): missing <param name=\"warnInvalid\">",
33-
"Unity.Netcode.NetworkPrefabs: bool Add(NetworkPrefab): missing <param name=\"networkPrefab\">",
34-
"Unity.Netcode.NetworkPrefabs: bool Add(NetworkPrefab): missing <returns>",
35-
"Unity.Netcode.NetworkPrefabs: void Remove(NetworkPrefab): missing <param name=\"prefab\">",
36-
"Unity.Netcode.NetworkPrefabs: void Remove(GameObject): missing <param name=\"prefab\">",
24+
"Unity.Netcode.NetworkConfig: AutoSpawnPlayerPrefabClientSide: undocumented",
3725
"Unity.Netcode.ConnectionEventData: EventType: undocumented",
3826
"Unity.Netcode.RpcException: undocumented",
3927
"Unity.Netcode.RpcException: .ctor(string): undocumented",
@@ -45,7 +33,6 @@
4533
"Unity.Netcode.CustomMessagingManager.HandleNamedMessageDelegate: missing <param name=\"messagePayload\">",
4634
"Unity.Netcode.GenerateSerializationForGenericParameterAttribute: .ctor(int): undocumented",
4735
"Unity.Netcode.GenerateSerializationForTypeAttribute: .ctor(Type): undocumented",
48-
4936
"Unity.Netcode.NetworkList<T>: void Finalize(): undocumented",
5037
"Unity.Netcode.NetworkVariable<T>: CheckExceedsDirtinessThreshold: undocumented",
5138
"Unity.Netcode.NetworkVariable<T>: bool ExceedsDirtinessThreshold(): undocumented",

0 commit comments

Comments
 (0)