forked from NetickNetworking/NetickForUnity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkInfo.cs
More file actions
33 lines (31 loc) · 1.23 KB
/
Copy pathNetworkInfo.cs
File metadata and controls
33 lines (31 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using UnityEngine;
using Netick;
using Netick.Unity;
using Network = Netick.Unity.Network;
namespace Netick.Samples
{
[AddComponentMenu("Netick/Network Info")]
public class NetworkInfo : NetworkEventsListener
{
private void OnGUI()
{
if (Network.Instance != null)
{
if (Sandbox != null && Sandbox.IsConnected)
{
Draw(0, "In", Sandbox.InKBps.ToString(), "KB/s");
Draw(1, "Out", Sandbox.OutKBps.ToString(), "KB/s");
Draw(2, "RTT", (Sandbox.RTT * 1000f).ToString(), "ms");
Draw(3, "Interp Delay", (Sandbox.InterpolationDelay * 1000f).ToString(), "ms");
Draw(4, "Resims", Sandbox.Monitor.Resimulations.Average.ToString(), "Ticks");
Draw(5, "Delta time", (Time.deltaTime * 1000f).ToString(), "ms");
}
}
}
private void Draw(int offset, string title, string content, string unit)
{
GUI.Label(new Rect(10, 10 + (15 * offset), 200, 50), $"{title}: ");
GUI.Label(new Rect(130, 10 + (15 * offset), 200, 50), $"{content} {unit}");
}
}
}