feat(Profiling): NetworkLoop sampling instead of "UpdateFunction.Invoke"

This commit is contained in:
miwarnec 2024-10-31 16:58:17 +01:00
parent e7b3aa77df
commit 2a992e6902

View File

@ -28,6 +28,7 @@
using UnityEngine;
using UnityEngine.LowLevel;
using UnityEngine.PlayerLoop;
using UnityEngine.Profiling;
namespace Mirror
{
@ -187,12 +188,17 @@ static void NetworkEarlyUpdate()
// however, we only want to call NetworkServer/Client in play mode.
if (!Application.isPlaying) return;
// profiling marker for shallow profiling to show more than "UpdateFunction.Invoke"
Profiler.BeginSample("NetworkEarlyUpdate");
NetworkTime.EarlyUpdate();
//Debug.Log($"NetworkEarlyUpdate {Time.time}");
NetworkServer.NetworkEarlyUpdate();
NetworkClient.NetworkEarlyUpdate();
// invoke event after mirror has done it's early updating.
OnEarlyUpdate?.Invoke();
Profiler.EndSample();
}
static void NetworkLateUpdate()
@ -201,11 +207,16 @@ static void NetworkLateUpdate()
// however, we only want to call NetworkServer/Client in play mode.
if (!Application.isPlaying) return;
// profiling marker for shallow profiling to show more than "UpdateFunction.Invoke"
Profiler.BeginSample("NetworkLateUpdate");
//Debug.Log($"NetworkLateUpdate {Time.time}");
// invoke event before mirror does its final late updating.
OnLateUpdate?.Invoke();
NetworkServer.NetworkLateUpdate();
NetworkClient.NetworkLateUpdate();
Profiler.EndSample();
}
}
}