From 9f0ecc81a6d8e031fd727ce39b94dcdd38cd17f2 Mon Sep 17 00:00:00 2001 From: Matthew Miner Date: Wed, 18 Mar 2020 20:56:47 -0700 Subject: [PATCH] Combine a few functions to improve readability --- Console.cs | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/Console.cs b/Console.cs index 27e924e..0530885 100644 --- a/Console.cs +++ b/Console.cs @@ -144,37 +144,29 @@ void Update() #endregion - void DrawCollapsedLog(Log log, GUIStyle logStyle, GUIStyle badgeStyle) - { - GUILayout.BeginHorizontal(); - - GUILayout.Label(log.GetTruncatedMessage(), logStyle); - GUILayout.FlexibleSpace(); - GUILayout.Label(log.count.ToString(), GUI.skin.box); - - GUILayout.EndHorizontal(); - } - - void DrawExpandedLog(Log log, GUIStyle logStyle) - { - for (var i = 0; i < log.count; i += 1) - { - GUILayout.Label(log.GetTruncatedMessage(), logStyle); - } - } - void DrawLog(Log log, GUIStyle logStyle, GUIStyle badgeStyle) { GUI.contentColor = logTypeColors[log.type]; if (isCollapsed) { - DrawCollapsedLog(log, logStyle, badgeStyle); + // Draw collapsed log with badge indicating count. + GUILayout.BeginHorizontal(); + GUILayout.Label(log.GetTruncatedMessage(), logStyle); + GUILayout.FlexibleSpace(); + GUILayout.Label(log.count.ToString(), GUI.skin.box); + GUILayout.EndHorizontal(); } else { - DrawExpandedLog(log, logStyle); + // Draw expanded log. + for (var i = 0; i < log.count; i += 1) + { + GUILayout.Label(log.GetTruncatedMessage(), logStyle); + } } + + GUI.contentColor = Color.white; } void DrawLogList() @@ -207,9 +199,6 @@ void DrawLogList() { ScrollToBottom(); } - - // Ensure GUI colour is reset before drawing other components. - GUI.contentColor = Color.white; } void DrawToolbar()