mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
feat(Profiling): NetworkLoop sampling instead of "UpdateFunction.Invoke"
This commit is contained in:
parent
e7b3aa77df
commit
2a992e6902
@ -28,6 +28,7 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.LowLevel;
|
using UnityEngine.LowLevel;
|
||||||
using UnityEngine.PlayerLoop;
|
using UnityEngine.PlayerLoop;
|
||||||
|
using UnityEngine.Profiling;
|
||||||
|
|
||||||
namespace Mirror
|
namespace Mirror
|
||||||
{
|
{
|
||||||
@ -187,12 +188,17 @@ static void NetworkEarlyUpdate()
|
|||||||
// however, we only want to call NetworkServer/Client in play mode.
|
// however, we only want to call NetworkServer/Client in play mode.
|
||||||
if (!Application.isPlaying) return;
|
if (!Application.isPlaying) return;
|
||||||
|
|
||||||
|
// profiling marker for shallow profiling to show more than "UpdateFunction.Invoke"
|
||||||
|
Profiler.BeginSample("NetworkEarlyUpdate");
|
||||||
|
|
||||||
NetworkTime.EarlyUpdate();
|
NetworkTime.EarlyUpdate();
|
||||||
//Debug.Log($"NetworkEarlyUpdate {Time.time}");
|
//Debug.Log($"NetworkEarlyUpdate {Time.time}");
|
||||||
NetworkServer.NetworkEarlyUpdate();
|
NetworkServer.NetworkEarlyUpdate();
|
||||||
NetworkClient.NetworkEarlyUpdate();
|
NetworkClient.NetworkEarlyUpdate();
|
||||||
// invoke event after mirror has done it's early updating.
|
// invoke event after mirror has done it's early updating.
|
||||||
OnEarlyUpdate?.Invoke();
|
OnEarlyUpdate?.Invoke();
|
||||||
|
|
||||||
|
Profiler.EndSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NetworkLateUpdate()
|
static void NetworkLateUpdate()
|
||||||
@ -201,11 +207,16 @@ static void NetworkLateUpdate()
|
|||||||
// however, we only want to call NetworkServer/Client in play mode.
|
// however, we only want to call NetworkServer/Client in play mode.
|
||||||
if (!Application.isPlaying) return;
|
if (!Application.isPlaying) return;
|
||||||
|
|
||||||
|
// profiling marker for shallow profiling to show more than "UpdateFunction.Invoke"
|
||||||
|
Profiler.BeginSample("NetworkLateUpdate");
|
||||||
|
|
||||||
//Debug.Log($"NetworkLateUpdate {Time.time}");
|
//Debug.Log($"NetworkLateUpdate {Time.time}");
|
||||||
// invoke event before mirror does its final late updating.
|
// invoke event before mirror does its final late updating.
|
||||||
OnLateUpdate?.Invoke();
|
OnLateUpdate?.Invoke();
|
||||||
NetworkServer.NetworkLateUpdate();
|
NetworkServer.NetworkLateUpdate();
|
||||||
NetworkClient.NetworkLateUpdate();
|
NetworkClient.NetworkLateUpdate();
|
||||||
|
|
||||||
|
Profiler.EndSample();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user