Fix ping
This commit is contained in:
parent
c33f3b7d58
commit
3d36d0d86d
@ -1,4 +1,5 @@
|
|||||||
using Cyber.Networking.Clientside;
|
using Cyber.Networking;
|
||||||
|
using Cyber.Networking.Clientside;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@ -12,6 +13,8 @@ public class NetworkDebugControl : MonoBehaviour {
|
|||||||
|
|
||||||
private bool visible = false;
|
private bool visible = false;
|
||||||
|
|
||||||
|
private double LastPingChecked = 0.5;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
|
|
||||||
@ -24,7 +27,11 @@ public class NetworkDebugControl : MonoBehaviour {
|
|||||||
ActualPanel.gameObject.SetActive(visible);
|
ActualPanel.gameObject.SetActive(visible);
|
||||||
}
|
}
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
LastPingChecked += Time.deltaTime;
|
||||||
|
if (LastPingChecked > 0.5) {
|
||||||
PingNumberText.text = ((int) (Client.GetSyncHandler().GetPing())) + "ms";
|
PingNumberText.text = ((int) (Client.GetSyncHandler().GetPing())) + "ms";
|
||||||
|
LastPingChecked -= 0.5;
|
||||||
|
}
|
||||||
PacketLossNumberText.text = ((int) (Client.GetSyncHandler().GetPacketLoss() * 10000) * 1f / 100) + "%";
|
PacketLossNumberText.text = ((int) (Client.GetSyncHandler().GetPacketLoss() * 10000) * 1f / 100) + "%";
|
||||||
PacketsReceivedNumberText.text = Client.GetSyncHandler().GetSyncPacketsReceived() + "";
|
PacketsReceivedNumberText.text = Client.GetSyncHandler().GetSyncPacketsReceived() + "";
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ namespace Cyber.Networking.Clientside {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float GetPing() {
|
public float GetPing() {
|
||||||
return (float) ((NetworkHelper.GetTime() - LastTimestamp) / 1000f);
|
return (float) ((NetworkHelper.GetTime() - LastTimestamp) * 1000f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetPacketLoss() {
|
public float GetPacketLoss() {
|
||||||
|
Loading…
Reference in New Issue
Block a user