This commit is contained in:
Sofia 2017-05-17 00:57:03 +03:00
parent c33f3b7d58
commit 3d36d0d86d
2 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,5 @@
using Cyber.Networking.Clientside;
using Cyber.Networking;
using Cyber.Networking.Clientside;
using UnityEngine;
using UnityEngine.UI;
@ -12,6 +13,8 @@ public class NetworkDebugControl : MonoBehaviour {
private bool visible = false;
private double LastPingChecked = 0.5;
// Use this for initialization
void Start () {
@ -24,7 +27,11 @@ public class NetworkDebugControl : MonoBehaviour {
ActualPanel.gameObject.SetActive(visible);
}
if (visible) {
PingNumberText.text = ((int) (Client.GetSyncHandler().GetPing())) + "ms";
LastPingChecked += Time.deltaTime;
if (LastPingChecked > 0.5) {
PingNumberText.text = ((int) (Client.GetSyncHandler().GetPing())) + "ms";
LastPingChecked -= 0.5;
}
PacketLossNumberText.text = ((int) (Client.GetSyncHandler().GetPacketLoss() * 10000) * 1f / 100) + "%";
PacketsReceivedNumberText.text = Client.GetSyncHandler().GetSyncPacketsReceived() + "";
}

View File

@ -71,7 +71,7 @@ namespace Cyber.Networking.Clientside {
}
public float GetPing() {
return (float) ((NetworkHelper.GetTime() - LastTimestamp) / 1000f);
return (float) ((NetworkHelper.GetTime() - LastTimestamp) * 1000f);
}
public float GetPacketLoss() {