Cyber/Assets/Scripts/Controls/NetworkDebugControl.cs

33 lines
941 B
C#
Raw Normal View History

2017-05-16 23:25:29 +02:00
using Cyber.Networking.Clientside;
using UnityEngine;
using UnityEngine.UI;
public class NetworkDebugControl : MonoBehaviour {
public Text PacketLossNumberText;
public Text PingNumberText;
public Text PacketsReceivedNumberText;
public RectTransform ActualPanel;
private bool visible = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("ToggleNetworkDebug")) {
visible = !visible && Client.IsRunning();
ActualPanel.gameObject.SetActive(visible);
}
if (visible) {
PingNumberText.text = ((int) (Client.GetSyncHandler().GetPing())) + "ms";
PacketLossNumberText.text = ((int) (Client.GetSyncHandler().GetPacketLoss() * 10000) * 1f / 100) + "%";
PacketsReceivedNumberText.text = Client.GetSyncHandler().GetSyncPacketsReceived() + "";
}
}
}