diff --git a/Assets/Mirror/Core/NetworkClient.cs b/Assets/Mirror/Core/NetworkClient.cs index 1584cb693..2813d22c8 100644 --- a/Assets/Mirror/Core/NetworkClient.cs +++ b/Assets/Mirror/Core/NetworkClient.cs @@ -1639,5 +1639,28 @@ public static void Shutdown() OnDisconnectedEvent = null; OnErrorEvent = null; } + // GUI ///////////////////////////////////////////////////////////////// + // called from NetworkManager to display timeline interpolation status. + // useful to indicate catchup / slowdown / dynamic adjustment etc. + internal static void OnGUI() + { + // only if in world + if (!ready) return; + + GUILayout.BeginArea(new Rect(10, 5, 400, 50)); + + GUILayout.BeginHorizontal("Box"); + GUILayout.Label("Snapshot Interp.:"); + // color while catching up / slowing down + if (localTimescale > 1) GUI.color = Color.green; // green traffic light = go fast + else if (localTimescale < 1) GUI.color = Color.red; // red traffic light = go slow + else GUI.color = Color.white; + GUILayout.Box($"timeline: {localTimeline:F2}"); + GUILayout.Box($"buffer: {snapshots.Count}"); + GUILayout.Box($"timescale: {localTimescale:F2}"); + GUILayout.EndHorizontal(); + + GUILayout.EndArea(); + } } } diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index d1fb89e99..30fbea40e 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -105,6 +105,9 @@ public class NetworkManager : MonoBehaviour public static List startPositions = new List(); public static int startPositionIndex; + [Header("Debug")] + public bool timeInterpolationGui = false; + /// The one and only NetworkManager public static NetworkManager singleton { get; internal set; } @@ -1342,5 +1345,12 @@ public virtual void OnStopClient() {} /// This is called when a host is stopped. public virtual void OnStopHost() {} + + // GUI ///////////////////////////////////////////////////////////////// + void OnGUI() + { + if (!timeInterpolationGui) return; + NetworkClient.OnGUI(); + } } }