This repository has been archived by the owner on Sep 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
NetworkStatistic.cs
52 lines (40 loc) · 1.87 KB
/
NetworkStatistic.cs
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using BeardedMonkeys;
using FishNet;
using UnityEngine;
public class NetworkStatistic : MonoBehaviour
{
[Tooltip("The transport which contains the calculation.")]
[SerializeField]
private FishyLatency m_transport;
private GUIStyle _style = new GUIStyle();
private void OnGUI()
{
_style.normal.textColor = Color.magenta;
_style.fontSize = 30;
_style.fontStyle = FontStyle.Bold;
float width = 85f;
float height = 15f;
float horizontal = 10f;
float vertical = 300f;
if(InstanceFinder.IsServer)
{
GUI.Label(new Rect(horizontal, vertical, width, height), $"Received Packets: {m_transport.ReceivedPacketsServer}/s", _style);
vertical += 25f;
GUI.Label(new Rect(horizontal, vertical, width, height), $"Received Bytes: {m_transport.ReceivedBytesServer}/s", _style);
vertical += 25f;
GUI.Label(new Rect(horizontal, vertical, width, height), $"Sent Packets: {m_transport.SentPacketsServer}/s", _style);
vertical += 25f;
GUI.Label(new Rect(horizontal, vertical, width, height), $"Sent Bytes: {m_transport.SentBytesServer}/s", _style);
}
else
{
GUI.Label(new Rect(horizontal, vertical, width, height), $"Received Packets: {m_transport.ReceivedPacketsClient}/s", _style);
vertical += 25f;
GUI.Label(new Rect(horizontal, vertical, width, height), $"Received Bytes: {m_transport.ReceivedBytesClient}/s", _style);
vertical += 25f;
GUI.Label(new Rect(horizontal, vertical, width, height), $"Sent Packets: {m_transport.SentPacketsClient}/s", _style);
vertical += 25f;
GUI.Label(new Rect(horizontal, vertical, width, height), $"Sent Bytes: {m_transport.SentBytesClient}/s", _style);
}
}
}