Skip to content

Commit 4400390

Browse files
fix: Realtime Network Stats Monitor Not Displaying RPC Metrics in Release Builds (#2980)
* fix Adding UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE to all of the various dependencies required to enable RNSM tracking of RPC messages. * update adding change log entry
1 parent f0db817 commit 4400390

File tree

7 files changed

+13
-12
lines changed

7 files changed

+13
-12
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1515

1616
### Fixed
1717

18+
- Fixed issue where the realtime network stats monitor was not able to display RPC traffic in release builds due to those stats being only available in development builds or the editor. (#2980)
1819
- Fixed issue where `NetworkManager.ScenesLoaded` was not being updated if `PostSynchronizationSceneUnloading` was set and any loaded scenes not used during synchronization were unloaded.(#2977)
1920
- Fixed issue where internal delta serialization could not have a byte serializer defined when serializing deltas for other types. Added `[GenerateSerializationForType(typeof(byte))]` to both the `NetworkVariable` and `AnticipatedNetworkVariable` classes to assure a byte serializer is defined. (#2953)
2021
- Fixed issue with the client count not being correct on the host or server side when a client disconnects itself from a session. (#2941)

com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public abstract class NetworkBehaviour : MonoBehaviour
2727
// RuntimeAccessModifiersILPP will make this `public`
2828
internal static readonly Dictionary<Type, Dictionary<uint, RpcReceiveHandler>> __rpc_func_table = new Dictionary<Type, Dictionary<uint, RpcReceiveHandler>>();
2929

30-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
30+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
3131
// RuntimeAccessModifiersILPP will make this `public`
3232
internal static readonly Dictionary<Type, Dictionary<uint, string>> __rpc_name_table = new Dictionary<Type, Dictionary<uint, string>>();
3333
#endif
@@ -123,7 +123,7 @@ internal void __endSendServerRpc(ref FastBufferWriter bufferWriter, uint rpcMeth
123123
}
124124

125125
bufferWriter.Dispose();
126-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
126+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
127127
if (__rpc_name_table[GetType()].TryGetValue(rpcMethodId, out var rpcMethodName))
128128
{
129129
NetworkManager.NetworkMetrics.TrackRpcSent(
@@ -254,7 +254,7 @@ internal void __endSendClientRpc(ref FastBufferWriter bufferWriter, uint rpcMeth
254254
}
255255

256256
bufferWriter.Dispose();
257-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
257+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
258258
if (__rpc_name_table[GetType()].TryGetValue(rpcMethodId, out var rpcMethodName))
259259
{
260260
if (clientRpcParams.Send.TargetClientIds != null)
@@ -832,7 +832,7 @@ internal void __registerRpc(uint hash, RpcReceiveHandler handler, string rpcMeth
832832
#pragma warning restore IDE1006 // restore naming rule violation check
833833
{
834834
__rpc_func_table[GetType()][hash] = handler;
835-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
835+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
836836
__rpc_name_table[GetType()][hash] = rpcMethodName;
837837
#endif
838838
}
@@ -858,7 +858,7 @@ internal void InitializeVariables()
858858
if (!__rpc_func_table.ContainsKey(GetType()))
859859
{
860860
__rpc_func_table[GetType()] = new Dictionary<uint, RpcReceiveHandler>();
861-
#if UNITY_EDITOR || DEVELOPMENT_BUILD
861+
#if UNITY_EDITOR || DEVELOPMENT_BUILD || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
862862
__rpc_name_table[GetType()] = new Dictionary<uint, string>();
863863
#endif
864864
__initializeRpcs();

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class NetworkManager : MonoBehaviour, INetworkUpdateSystem
2727
// RuntimeAccessModifiersILPP will make this `public`
2828
internal static readonly Dictionary<uint, RpcReceiveHandler> __rpc_func_table = new Dictionary<uint, RpcReceiveHandler>();
2929

30-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
30+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
3131
// RuntimeAccessModifiersILPP will make this `public`
3232
internal static readonly Dictionary<uint, string> __rpc_name_table = new Dictionary<uint, string>();
3333
#endif

com.unity.netcode.gameobjects/Runtime/Messaging/Messages/RpcMessages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static unsafe bool Deserialize(ref FastBufferReader reader, ref NetworkCo
4141

4242
payload = new FastBufferReader(reader.GetUnsafePtrAtCurrentPosition(), Allocator.None, reader.Length - reader.Position);
4343

44-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
44+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
4545
if (NetworkBehaviour.__rpc_name_table[networkBehaviour.GetType()].TryGetValue(metadata.NetworkRpcMethodId, out var rpcMethodName))
4646
{
4747
networkManager.NetworkMetrics.TrackRpcReceived(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ protected void CheckLockBeforeDispose()
3636

3737
private protected void SendMessageToClient(NetworkBehaviour behaviour, ulong clientId, ref RpcMessage message, NetworkDelivery delivery)
3838
{
39-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
39+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
4040
var size =
4141
#endif
4242
behaviour.NetworkManager.MessageManager.SendMessage(ref message, delivery, clientId);
4343

44-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
44+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
4545
if (NetworkBehaviour.__rpc_name_table[behaviour.GetType()].TryGetValue(message.Metadata.NetworkRpcMethodId, out var rpcMethodName))
4646
{
4747
behaviour.NetworkManager.NetworkMetrics.TrackRpcSent(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal override void Send(NetworkBehaviour behaviour, ref RpcMessage message,
4646
message.Handle(ref context);
4747
length = tempBuffer.Length;
4848
}
49-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
49+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
5050
if (NetworkBehaviour.__rpc_name_table[behaviour.GetType()].TryGetValue(message.Metadata.NetworkRpcMethodId, out var rpcMethodName))
5151
{
5252
behaviour.NetworkManager.NetworkMetrics.TrackRpcSent(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ internal class ProxyRpcTargetGroup : BaseRpcTarget, IDisposable, IGroupRpcTarget
1818
internal override void Send(NetworkBehaviour behaviour, ref RpcMessage message, NetworkDelivery delivery, RpcParams rpcParams)
1919
{
2020
var proxyMessage = new ProxyMessage { Delivery = delivery, TargetClientIds = TargetClientIds.AsArray(), WrappedMessage = message };
21-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
21+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
2222
var size =
2323
#endif
2424
behaviour.NetworkManager.MessageManager.SendMessage(ref proxyMessage, delivery, NetworkManager.ServerClientId);
2525

26-
#if DEVELOPMENT_BUILD || UNITY_EDITOR
26+
#if DEVELOPMENT_BUILD || UNITY_EDITOR || UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE
2727
if (NetworkBehaviour.__rpc_name_table[behaviour.GetType()].TryGetValue(message.Metadata.NetworkRpcMethodId, out var rpcMethodName))
2828
{
2929
foreach (var clientId in TargetClientIds)

0 commit comments

Comments
 (0)