コード例 #1
0
        public void Draw(ref bool foldout, float width, NetworkTrafic trafic)
        {
            var cellWidth = (width - 20) / 6f;

            foldout = EditorGUILayout.Foldout(foldout, m_Label);
            EditorGUI.indentLevel++;
            if (foldout)
            {
                GUILayout.Label("By Channel", EditorStyles.boldLabel);;
                DrawChannel(cellWidth, trafic);
                GUILayout.Label("By Message", EditorStyles.boldLabel);;
                DrawMessage(cellWidth, trafic);
            }
            EditorGUI.indentLevel--;
        }
コード例 #2
0
        void DrawChannel(float cellWidth, NetworkTrafic trafic)
        {
            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            GUILayout.Label("Id", EditorStyles.boldLabel, GUILayout.Width(cellWidth));
            GUILayout.Label("Count", EditorStyles.boldLabel, GUILayout.Width(cellWidth));
            GUILayout.Label("Total\n(byte)", EditorStyles.boldLabel, GUILayout.Width(cellWidth));
            GUILayout.Label(" Avg\n(byte)", EditorStyles.boldLabel, GUILayout.Width(cellWidth));
            GUILayout.Label(" Min\n(byte)", EditorStyles.boldLabel, GUILayout.Width(cellWidth));
            GUILayout.Label(" Max\n(byte)", EditorStyles.boldLabel, GUILayout.Width(cellWidth));
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical();
            if (trafic != null && trafic.ChannelTrafics.Count > 0)
            {
                var channelTrafics = trafic.ChannelTrafics;

                foreach (var item in channelTrafics)
                {
                    var info = item.Value;

                    GUILayout.BeginHorizontal(EditorStyles.helpBox);
                    GUILayout.Label(info.Category, GUILayout.Width(cellWidth));
                    GUILayout.Label(info.Count.ToString(), GUILayout.Width(cellWidth));
                    GUILayout.Label(info.Total.ToString(), GUILayout.Width(cellWidth));
                    GUILayout.Label(info.Avg.ToString(), GUILayout.Width(cellWidth));
                    GUILayout.Label(info.Min.ToString(), GUILayout.Width(cellWidth));
                    GUILayout.Label(info.Max.ToString(), GUILayout.Width(cellWidth));
                    GUILayout.EndHorizontal();
                }
            }
            else
            {
                string empty = "-";
                GUILayout.BeginHorizontal(EditorStyles.helpBox);
                GUILayout.Label(empty, GUILayout.Width(cellWidth));
                GUILayout.Label(empty, GUILayout.Width(cellWidth));
                GUILayout.Label(empty, GUILayout.Width(cellWidth));
                GUILayout.Label(empty, GUILayout.Width(cellWidth));
                GUILayout.Label(empty, GUILayout.Width(cellWidth));
                GUILayout.Label(empty, GUILayout.Width(cellWidth));
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
        }