Skip to content

Commit 9813c0d

Browse files
update
Adding XML API documentation for RpcTargetUse.
1 parent 0cd32e0 commit 9813c0d

File tree

1 file changed

+19
-0
lines changed
  • com.unity.netcode.gameobjects/Runtime/Messaging/RpcTargets

1 file changed

+19
-0
lines changed

com.unity.netcode.gameobjects/Runtime/Messaging/RpcTargets/RpcTarget.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,28 @@ public enum SendTo
7979
SpecifiedInParams
8080
}
8181

82+
/// <summary>
83+
/// This parameter controls the use of a particular performance optimization in situations where it can be used.<br />
84+
/// Because BaseRpcTarget is a managed type, allocating a new one is expensive, as it puts pressure on the garbage collector.
85+
/// </summary>
86+
/// <remarks>
87+
/// When using a <see cref="Temp"/> allocation type for the RPC target(s):<br />
88+
/// You typically don't need to worry about persisting the <see cref="BaseRpcTarget"/> generated.
89+
/// When using a <see cref="Persistent"/> allocation type for the RPC target(s): <br />
90+
/// You will want to use <see cref="RpcTarget"/>, which returns <see cref="BaseRpcTarget"/>, during <see cref="NetworkBehaviour"/> initialization (i.e. <see cref="NetworkBehaviour.OnNetworkPostSpawn"/>) and it to a property.<br />
91+
/// Then, When invoking the RPC, you would use your <see cref="BaseRpcTarget"/> which is a persisted allocation of a given set of client identifiers.
92+
/// !! Important !!<br />
93+
/// You will want to invoke <see cref="BaseRpcTarget.Dispose"/> of any persisted properties created via <see cref="RpcTarget"/> when despawning or destroying the associated <see cref="NetworkBehaviour"/> component's <see cref="NetworkObject"/>. Not doing so will result in small memory leaks.
94+
/// </remarks>
8295
public enum RpcTargetUse
8396
{
97+
/// <summary>
98+
/// Creates a temporary <see cref="BaseRpcTarget"/> used for the frame an <see cref="RpcAttribute"/> decorated method is invoked.
99+
/// </summary>
84100
Temp,
101+
/// <summary>
102+
/// Creates a persisted <see cref="BaseRpcTarget"/> that does not change and persists until it is disposed.
103+
/// </summary>
85104
Persistent
86105
}
87106

0 commit comments

Comments
 (0)