Skip to content

Commit b120470

Browse files
committed
- Added an option to show popup only when a log is received
- Added opacity settings for log window and popup (closed #90) - Combined "Start Minimized" and "Enable Popup" options (only "Start Minimized" remains)
1 parent c6af7bd commit b120470

File tree

5 files changed

+80
-22
lines changed

5 files changed

+80
-22
lines changed

Plugins/IngameDebugConsole/Editor/DebugLogManagerEditor.cs

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ public class DebugLogManagerEditor : Editor
1111
private SerializedProperty enableHorizontalResizing;
1212
private SerializedProperty resizeFromRight;
1313
private SerializedProperty minimumWidth;
14-
private SerializedProperty enablePopup;
15-
private SerializedProperty startInPopupMode;
14+
private SerializedProperty logWindowOpacity;
15+
private SerializedProperty popupOpacity;
16+
private SerializedProperty popupVisibility;
17+
private SerializedProperty popupVisibilityLogFilter;
1618
private SerializedProperty startMinimized;
1719
private SerializedProperty toggleWithKey;
1820
private SerializedProperty toggleKey;
@@ -37,6 +39,9 @@ public class DebugLogManagerEditor : Editor
3739
private SerializedProperty popupAvoidsScreenCutout;
3840
private SerializedProperty autoFocusOnCommandInputField;
3941

42+
#if UNITY_2017_3_OR_NEWER
43+
private readonly GUIContent popupVisibilityLogFilterLabel = new GUIContent( "Log Filter", "Determines which log types will show the popup on screen" );
44+
#endif
4045
private readonly GUIContent receivedLogTypesLabel = new GUIContent( "Received Log Types", "Only these logs will be received by the console window, other logs will simply be skipped" );
4146
private readonly GUIContent receiveInfoLogsLabel = new GUIContent( "Info" );
4247
private readonly GUIContent receiveWarningLogsLabel = new GUIContent( "Warning" );
@@ -50,8 +55,10 @@ private void OnEnable()
5055
enableHorizontalResizing = serializedObject.FindProperty( "enableHorizontalResizing" );
5156
resizeFromRight = serializedObject.FindProperty( "resizeFromRight" );
5257
minimumWidth = serializedObject.FindProperty( "minimumWidth" );
53-
enablePopup = serializedObject.FindProperty( "enablePopup" );
54-
startInPopupMode = serializedObject.FindProperty( "startInPopupMode" );
58+
logWindowOpacity = serializedObject.FindProperty( "logWindowOpacity" );
59+
popupOpacity = serializedObject.FindProperty( "popupOpacity" );
60+
popupVisibility = serializedObject.FindProperty( "popupVisibility" );
61+
popupVisibilityLogFilter = serializedObject.FindProperty( "popupVisibilityLogFilter" );
5562
startMinimized = serializedObject.FindProperty( "startMinimized" );
5663
toggleWithKey = serializedObject.FindProperty( "toggleWithKey" );
5764
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
@@ -103,11 +110,26 @@ public override void OnInspectorGUI()
103110

104111
EditorGUILayout.Space();
105112

106-
EditorGUILayout.PropertyField( enablePopup );
107-
if( enablePopup.boolValue )
108-
DrawSubProperty( startInPopupMode );
109-
else
110-
DrawSubProperty( startMinimized );
113+
EditorGUILayout.PropertyField( startMinimized );
114+
EditorGUILayout.PropertyField( logWindowOpacity );
115+
EditorGUILayout.PropertyField( popupOpacity );
116+
117+
EditorGUILayout.PropertyField( popupVisibility );
118+
if( popupVisibility.intValue == (int) PopupVisibility.WhenLogReceived )
119+
{
120+
EditorGUI.indentLevel++;
121+
#if UNITY_2017_3_OR_NEWER
122+
popupVisibilityLogFilter.intValue = (int) (DebugLogFilter) EditorGUILayout.EnumFlagsField( popupVisibilityLogFilterLabel, (DebugLogFilter) popupVisibilityLogFilter.intValue );
123+
#else
124+
EditorGUI.BeginChangeCheck();
125+
bool infoLog = EditorGUILayout.Toggle( "Info", ( (DebugLogFilter) popupVisibilityLogFilter.intValue & DebugLogFilter.Info ) == DebugLogFilter.Info );
126+
bool warningLog = EditorGUILayout.Toggle( "Warning", ( (DebugLogFilter) popupVisibilityLogFilter.intValue & DebugLogFilter.Warning ) == DebugLogFilter.Warning );
127+
bool errorLog = EditorGUILayout.Toggle( "Error", ( (DebugLogFilter) popupVisibilityLogFilter.intValue & DebugLogFilter.Error ) == DebugLogFilter.Error );
128+
if( EditorGUI.EndChangeCheck() )
129+
popupVisibilityLogFilter.intValue = ( infoLog ? (int) DebugLogFilter.Info : 0 ) | ( warningLog ? (int) DebugLogFilter.Warning : 0 ) | ( errorLog ? (int) DebugLogFilter.Error : 0 );
130+
#endif
131+
EditorGUI.indentLevel--;
132+
}
111133

112134
EditorGUILayout.PropertyField( toggleWithKey );
113135
if( toggleWithKey.boolValue )

Plugins/IngameDebugConsole/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= In-game Debug Console (v1.6.6) =
1+
= In-game Debug Console (v1.6.7) =
22

33
Documentation: https://github.com/yasirkula/UnityIngameDebugConsole
44
FAQ: https://github.com/yasirkula/UnityIngameDebugConsole#faq

Plugins/IngameDebugConsole/Scripts/DebugLogManager.cs

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ public enum DebugLogFilter
3232
Info = 1,
3333
Warning = 2,
3434
Error = 4,
35-
All = 7
35+
All = ~0
36+
}
37+
38+
public enum PopupVisibility
39+
{
40+
Always = 0,
41+
WhenLogReceived = 1,
42+
Never = 2
3643
}
3744

3845
public class DebugLogManager : MonoBehaviour
@@ -68,13 +75,25 @@ public class DebugLogManager : MonoBehaviour
6875

6976
[SerializeField]
7077
[HideInInspector]
71-
[Tooltip( "If disabled, no popup will be shown when the console window is hidden" )]
72-
private bool enablePopup = true;
78+
[Tooltip( "Opacity of the console window" )]
79+
[Range( 0f, 1f )]
80+
private float logWindowOpacity = 1f;
81+
82+
[SerializeField]
83+
[HideInInspector]
84+
[Tooltip( "Opacity of the popup" )]
85+
[Range( 0f, 1f )]
86+
internal float popupOpacity = 1f;
7387

7488
[SerializeField]
7589
[HideInInspector]
76-
[Tooltip( "If enabled, console will be initialized as a popup" )]
77-
private bool startInPopupMode = true;
90+
[Tooltip( "Determines when the popup will show up (after the console window is closed)" )]
91+
private PopupVisibility popupVisibility = PopupVisibility.Always;
92+
93+
[SerializeField]
94+
[HideInInspector]
95+
[Tooltip( "Determines which log types will show the popup on screen" )]
96+
private DebugLogFilter popupVisibilityLogFilter = DebugLogFilter.All;
7897

7998
[SerializeField]
8099
[HideInInspector]
@@ -630,12 +649,12 @@ private void OnDisable()
630649

631650
private void Start()
632651
{
633-
if( ( enablePopup && startInPopupMode ) || ( !enablePopup && startMinimized ) )
652+
if( startMinimized )
634653
HideLogWindow();
635654
else
636655
ShowLogWindow();
637656

638-
PopupEnabled = enablePopup;
657+
PopupEnabled = ( popupVisibility != PopupVisibility.Never );
639658
}
640659

641660
private void OnDestroy()
@@ -781,7 +800,19 @@ private void LateUpdate()
781800
if( !isLogWindowVisible )
782801
{
783802
entryCountTextsDirty = true;
784-
popupManager.NewLogsArrived( newInfoEntryCount, newWarningEntryCount, newErrorEntryCount );
803+
804+
if( popupVisibility == PopupVisibility.WhenLogReceived && !popupManager.IsVisible )
805+
{
806+
if( ( newInfoEntryCount > 0 && ( popupVisibilityLogFilter & DebugLogFilter.Info ) == DebugLogFilter.Info ) ||
807+
( newWarningEntryCount > 0 && ( popupVisibilityLogFilter & DebugLogFilter.Warning ) == DebugLogFilter.Warning ) ||
808+
( newErrorEntryCount > 0 && ( popupVisibilityLogFilter & DebugLogFilter.Error ) == DebugLogFilter.Error ) )
809+
{
810+
popupManager.Show();
811+
}
812+
}
813+
814+
if( popupManager.IsVisible )
815+
popupManager.NewLogsArrived( newInfoEntryCount, newWarningEntryCount, newErrorEntryCount );
785816
}
786817
}
787818

@@ -925,7 +956,7 @@ public void ShowLogWindow()
925956
{
926957
// Show the log window
927958
logWindowCanvasGroup.blocksRaycasts = true;
928-
logWindowCanvasGroup.alpha = 1f;
959+
logWindowCanvasGroup.alpha = logWindowOpacity;
929960

930961
popupManager.Hide();
931962

@@ -954,7 +985,8 @@ public void HideLogWindow()
954985
if( commandInputField.isFocused )
955986
commandInputField.DeactivateInputField();
956987

957-
popupManager.Show();
988+
if( popupVisibility == PopupVisibility.Always )
989+
popupManager.Show();
958990

959991
isLogWindowVisible = false;
960992

Plugins/IngameDebugConsole/Scripts/DebugLogPopup.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public class DebugLogPopup : MonoBehaviour, IPointerClickHandler, IBeginDragHand
5252
// Coroutines for simple code-based animations
5353
private IEnumerator moveToPosCoroutine = null;
5454

55+
public bool IsVisible { get; private set; }
56+
5557
private void Awake()
5658
{
5759
popupTransform = (RectTransform) transform;
@@ -137,7 +139,8 @@ public void OnPointerClick( PointerEventData data )
137139
public void Show()
138140
{
139141
canvasGroup.blocksRaycasts = true;
140-
canvasGroup.alpha = 1f;
142+
canvasGroup.alpha = debugManager.popupOpacity;
143+
IsVisible = true;
141144

142145
// Reset the counters
143146
ResetValues();
@@ -152,6 +155,7 @@ public void Hide()
152155
canvasGroup.blocksRaycasts = false;
153156
canvasGroup.alpha = 0f;
154157

158+
IsVisible = false;
155159
isPopupBeingDragged = false;
156160
}
157161

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.yasirkula.ingamedebugconsole",
33
"displayName": "In-game Debug Console",
4-
"version": "1.6.6",
4+
"version": "1.6.7",
55
"documentationUrl": "https://github.com/yasirkula/UnityIngameDebugConsole",
66
"changelogUrl": "https://github.com/yasirkula/UnityIngameDebugConsole/releases",
77
"licensesUrl": "https://github.com/yasirkula/UnityIngameDebugConsole/blob/master/LICENSE.txt",

0 commit comments

Comments
 (0)