This commit is contained in:
vis2k 2022-10-03 13:20:05 +02:00
parent 868f261612
commit f1a86ee66e
2 changed files with 33 additions and 0 deletions

View File

@ -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();
}
}
}

View File

@ -105,6 +105,9 @@ public class NetworkManager : MonoBehaviour
public static List<Transform> startPositions = new List<Transform>();
public static int startPositionIndex;
[Header("Debug")]
public bool timeInterpolationGui = false;
/// <summary>The one and only NetworkManager</summary>
public static NetworkManager singleton { get; internal set; }
@ -1342,5 +1345,12 @@ public virtual void OnStopClient() {}
/// <summary>This is called when a host is stopped.</summary>
public virtual void OnStopHost() {}
// GUI /////////////////////////////////////////////////////////////////
void OnGUI()
{
if (!timeInterpolationGui) return;
NetworkClient.OnGUI();
}
}
}