private void RenderPacketList(ToRender toRender) { bool isSentList = toRender.HasFlag(ToRender.SENT); bool isReceiveList = toRender.HasFlag(ToRender.RECEIVED); PacketPrefixer prefixer = isSentList && isReceiveList ? (PacketPrefixer)PacketDirectionPrefixer : PacketNoopPrefixer; for (int i = packets.Count - 1; i >= 0; i--) { PacketDebugWrapper wrapper = packets[i]; if (wrapper.IsSent && !isSentList) { continue; } if (!wrapper.IsSent && !isReceiveList) { continue; } using (new GUILayout.VerticalScope("Box")) { using (new GUILayout.HorizontalScope()) { wrapper.ShowDetails = GUILayout.Toggle(wrapper.ShowDetails, "", GUILayout.Width(20), GUILayout.Height(20)); GUILayout.Label($"{prefixer(wrapper)}{wrapper.Packet.GetType().FullName}", wrapper.IsSent ? "packet-type-up" : "packet-type-down"); packets[i] = wrapper; // Store again because value-type } if (wrapper.ShowDetails) { GUILayout.Label(wrapper.Packet.ToString()); } } } }
private string PacketNoopPrefixer(PacketDebugWrapper wraper) => "";
private string PacketDirectionPrefixer(PacketDebugWrapper wrapper) => $"{(wrapper.IsSent ? "↑" : "↓")} - ";