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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Network Statistic calculation (byte per sec etc.) by default…
… it's enabled - Added a sample (NetworkStatistic.cs) how to display those statistics
- Loading branch information
TiToMoskito
committed
Jan 19, 2022
1 parent
1651e0d
commit 866d45e
Showing
4 changed files
with
208 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 = 24; | ||
_style.fontStyle = FontStyle.Bold; | ||
|
||
float width = 85f; | ||
float height = 15f; | ||
|
||
float horizontal = 10f; | ||
float vertical = 10f; | ||
|
||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.2.0 | ||
1.3.0 |