Exemplo n.º 1
0
        private void OnTickRecorded(NetworkProfileTick obj)
        {
            this.ticks.Add(obj);

            if (this.ticks.Count > 300)
            {
                this.ticks.RemoveAt(0);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Completes the collection of this frame and marks the frame tick
        /// </summary>
        /// <param name="newTime"></param>
        public static void Tick(float newTime)
        {
#if !MIRROR_PROFILING
            throw new InvalidOperationException("Network Profiling Ticks will return nothing without setting the MIRROR_PROFILING define");
#endif

            if (NetworkProfiler.IsRecording)
            {
                NetworkProfiler.CurrentTick.Time = newTime;
                NetworkProfiler.TickRecorded?.Invoke(NetworkProfiler.CurrentTick);
                NetworkProfiler.CurrentTick = new NetworkProfileTick();
            }
        }
Exemplo n.º 3
0
        public void OnGUI()
        {
            if (this.headerStyle == null)
            {
                this.headerStyle = new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.MiddleLeft, fontStyle = FontStyle.Bold, fontSize = 14
                };
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical(GUILayout.Width(250));

            NetworkProfiler.IsRecording = GUILayout.Toggle(NetworkProfiler.IsRecording, "Record", "Button");
            EditorGUILayout.Space();

            this.leftScrollPosition = EditorGUILayout.BeginScrollView(this.leftScrollPosition);

            for (int x = this.ticks.Count - 1; x > -1; x--)
            {
                NetworkProfileTick t = this.ticks[x];
                if (GUILayout.Button($"{t.Time} - {t.TotalMessages} Messages "))
                {
                    this.Show(t);
                }
                ;
            }

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            // Tick Inspector Window
            EditorGUILayout.BeginVertical();
            this.rightScrollPosition = EditorGUILayout.BeginScrollView(this.rightScrollPosition);
            if (this.selectedTick != null)
            {
                EditorGUILayout.LabelField($"Time : {this.selectedTick.Time}", this.headerStyle);

                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Channels", this.headerStyle);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Channel", GUILayout.Width(ChannelColumnWidth));
                GUILayout.Label("Bytes In", GUILayout.Width(ChannelColumnWidth));
                GUILayout.Label("Bytes Out", GUILayout.Width(ChannelColumnWidth));
                GUILayout.EndHorizontal();
                foreach (NetworkProfileChannel c in this.selectedTick.Channels)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(c.Id.ToString(), GUILayout.Width(ChannelColumnWidth));
                    GUILayout.Label(c.BytesIncoming.ToString(), GUILayout.Width(ChannelColumnWidth));
                    GUILayout.Label(c.BytesOutgoing.ToString(), GUILayout.Width(ChannelColumnWidth));
                    GUILayout.EndHorizontal();
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Messages", this.headerStyle);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Direction", GUILayout.Width(75));
                GUILayout.Label("Count", GUILayout.Width(75));
                GUILayout.Label("Type", GUILayout.Width(MessageColumnWidth * 4));
                GUILayout.Label("Name", GUILayout.Width(MessageColumnWidth * 4));
                GUILayout.EndHorizontal();
                foreach (NetworkProfileMessage m in this.selectedTick.Messages)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(m.Direction.ToString(), GUILayout.Width(75));
                    GUILayout.Label(m.Count.ToString(), GUILayout.Width(75));
                    GUILayout.Label(m.Type.ToString(), GUILayout.Width(MessageColumnWidth * 4));
                    GUILayout.Label(m.Name.ToString(), GUILayout.Width(MessageColumnWidth * 4));
                    GUILayout.EndHorizontal();
                }

                EditorGUILayout.Space();
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();
            this.Repaint();
        }
Exemplo n.º 4
0
 public void Show(NetworkProfileTick tick)
 {
     this.selectedTick = tick;
 }