Example #1
0
        void OnGUI()
        {
            if (simpleTreeView == null)
            {
                return;
            }

            if (CurrentFrame == null)
            {
                CurrentFrame = new Frame();
            }

            activeDebugger = this;

            tab = GUILayout.Toolbar(tab, new string[] { "Frames", "Server Statistics" });
            switch (tab)
            {
            case 0:
                simpleTreeView.Debugger = this;
                simpleTreeView.Reload();
                simpleTreeView.OnGUI(new Rect(0, 20, position.width, position.height));
                break;

            case 1:
                foreach (var line in Statistics)
                {
                    GUILayout.Label(line);
                }
                Repaint();
                break;
            }
        }
        public void Update()
        {
            server.PollEvents();

#if UNITY_EDITOR
            TransportDebugger.CycleFrame();

            {
                var f = server.Statistics.BytesSent / Time.time;
                f /= 1024; // b -> kb
                var f2 = Mathf.RoundToInt(f * 100) * 0.01f;

                TransportDebugger.ReportStatistic($"out {server.Statistics.PacketsSent} {f2}kb/s");
            }
            {
                var f = server.Statistics.BytesReceived / Time.time;
                f /= 1024; // b -> kb
                var f2 = Mathf.RoundToInt(f * 100) * 0.01f;

                TransportDebugger.ReportStatistic($"in {server.Statistics.PacketsSent} {f2}kb/s");
            }
#endif
        }