DebugLogManagerEditor.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace IngameDebugConsole
  4. {
  5. [CustomEditor( typeof( DebugLogManager ) )]
  6. public class DebugLogManagerEditor : Editor
  7. {
  8. private SerializedProperty singleton;
  9. private SerializedProperty minimumHeight;
  10. private SerializedProperty enableHorizontalResizing;
  11. private SerializedProperty resizeFromRight;
  12. private SerializedProperty minimumWidth;
  13. private SerializedProperty logWindowOpacity;
  14. private SerializedProperty popupOpacity;
  15. private SerializedProperty popupVisibility;
  16. private SerializedProperty popupVisibilityLogFilter;
  17. private SerializedProperty startMinimized;
  18. private SerializedProperty toggleWithKey;
  19. private SerializedProperty toggleKey;
  20. private SerializedProperty enableSearchbar;
  21. private SerializedProperty topSearchbarMinWidth;
  22. private SerializedProperty copyAllLogsOnResizeButtonClick;
  23. private SerializedProperty receiveLogsWhileInactive;
  24. private SerializedProperty receiveInfoLogs;
  25. private SerializedProperty receiveWarningLogs;
  26. private SerializedProperty receiveErrorLogs;
  27. private SerializedProperty receiveExceptionLogs;
  28. private SerializedProperty captureLogTimestamps;
  29. private SerializedProperty alwaysDisplayTimestamps;
  30. private SerializedProperty maxLogCount;
  31. private SerializedProperty logsToRemoveAfterMaxLogCount;
  32. private SerializedProperty queuedLogLimit;
  33. private SerializedProperty clearCommandAfterExecution;
  34. private SerializedProperty commandHistorySize;
  35. private SerializedProperty showCommandSuggestions;
  36. private SerializedProperty receiveLogcatLogsInAndroid;
  37. private SerializedProperty logcatArguments;
  38. private SerializedProperty avoidScreenCutout;
  39. private SerializedProperty popupAvoidsScreenCutout;
  40. private SerializedProperty autoFocusOnCommandInputField;
  41. private readonly GUIContent popupVisibilityLogFilterLabel = new GUIContent( "Log Filter", "Determines which log types will show the popup on screen" );
  42. 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" );
  43. private readonly GUIContent receiveInfoLogsLabel = new GUIContent( "Info" );
  44. private readonly GUIContent receiveWarningLogsLabel = new GUIContent( "Warning" );
  45. private readonly GUIContent receiveErrorLogsLabel = new GUIContent( "Error" );
  46. private readonly GUIContent receiveExceptionLogsLabel = new GUIContent( "Exception" );
  47. private void OnEnable()
  48. {
  49. singleton = serializedObject.FindProperty( "singleton" );
  50. minimumHeight = serializedObject.FindProperty( "minimumHeight" );
  51. enableHorizontalResizing = serializedObject.FindProperty( "enableHorizontalResizing" );
  52. resizeFromRight = serializedObject.FindProperty( "resizeFromRight" );
  53. minimumWidth = serializedObject.FindProperty( "minimumWidth" );
  54. logWindowOpacity = serializedObject.FindProperty( "logWindowOpacity" );
  55. popupOpacity = serializedObject.FindProperty( "popupOpacity" );
  56. popupVisibility = serializedObject.FindProperty( "popupVisibility" );
  57. popupVisibilityLogFilter = serializedObject.FindProperty( "popupVisibilityLogFilter" );
  58. startMinimized = serializedObject.FindProperty( "startMinimized" );
  59. toggleWithKey = serializedObject.FindProperty( "toggleWithKey" );
  60. #if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
  61. toggleKey = serializedObject.FindProperty( "toggleBinding" );
  62. #else
  63. toggleKey = serializedObject.FindProperty( "toggleKey" );
  64. #endif
  65. enableSearchbar = serializedObject.FindProperty( "enableSearchbar" );
  66. topSearchbarMinWidth = serializedObject.FindProperty( "topSearchbarMinWidth" );
  67. receiveLogsWhileInactive = serializedObject.FindProperty( "receiveLogsWhileInactive" );
  68. receiveInfoLogs = serializedObject.FindProperty( "receiveInfoLogs" );
  69. receiveWarningLogs = serializedObject.FindProperty( "receiveWarningLogs" );
  70. receiveErrorLogs = serializedObject.FindProperty( "receiveErrorLogs" );
  71. receiveExceptionLogs = serializedObject.FindProperty( "receiveExceptionLogs" );
  72. captureLogTimestamps = serializedObject.FindProperty( "captureLogTimestamps" );
  73. alwaysDisplayTimestamps = serializedObject.FindProperty( "alwaysDisplayTimestamps" );
  74. maxLogCount = serializedObject.FindProperty( "maxLogCount" );
  75. logsToRemoveAfterMaxLogCount = serializedObject.FindProperty( "logsToRemoveAfterMaxLogCount" );
  76. queuedLogLimit = serializedObject.FindProperty( "queuedLogLimit" );
  77. copyAllLogsOnResizeButtonClick = serializedObject.FindProperty("copyAllLogsOnResizeButtonClick");
  78. clearCommandAfterExecution = serializedObject.FindProperty( "clearCommandAfterExecution" );
  79. commandHistorySize = serializedObject.FindProperty( "commandHistorySize" );
  80. showCommandSuggestions = serializedObject.FindProperty( "showCommandSuggestions" );
  81. receiveLogcatLogsInAndroid = serializedObject.FindProperty( "receiveLogcatLogsInAndroid" );
  82. logcatArguments = serializedObject.FindProperty( "logcatArguments" );
  83. avoidScreenCutout = serializedObject.FindProperty( "avoidScreenCutout" );
  84. popupAvoidsScreenCutout = serializedObject.FindProperty( "popupAvoidsScreenCutout" );
  85. autoFocusOnCommandInputField = serializedObject.FindProperty( "autoFocusOnCommandInputField" );
  86. }
  87. public override void OnInspectorGUI()
  88. {
  89. serializedObject.Update();
  90. EditorGUILayout.PropertyField( singleton );
  91. EditorGUILayout.Space();
  92. EditorGUILayout.PropertyField( minimumHeight );
  93. EditorGUILayout.PropertyField( enableHorizontalResizing );
  94. if( enableHorizontalResizing.boolValue )
  95. {
  96. DrawSubProperty( resizeFromRight );
  97. DrawSubProperty( minimumWidth );
  98. }
  99. EditorGUILayout.PropertyField( avoidScreenCutout );
  100. DrawSubProperty( popupAvoidsScreenCutout );
  101. EditorGUILayout.Space();
  102. EditorGUILayout.PropertyField( startMinimized );
  103. EditorGUILayout.PropertyField( logWindowOpacity );
  104. EditorGUILayout.PropertyField( popupOpacity );
  105. EditorGUILayout.PropertyField( popupVisibility );
  106. if( popupVisibility.intValue == (int) PopupVisibility.WhenLogReceived )
  107. {
  108. EditorGUI.indentLevel++;
  109. Rect rect = EditorGUILayout.GetControlRect();
  110. EditorGUI.BeginProperty( rect, GUIContent.none, popupVisibilityLogFilter );
  111. popupVisibilityLogFilter.intValue = (int) (DebugLogFilter) EditorGUI.EnumFlagsField( rect, popupVisibilityLogFilterLabel, (DebugLogFilter) popupVisibilityLogFilter.intValue );
  112. EditorGUI.EndProperty();
  113. EditorGUI.indentLevel--;
  114. }
  115. EditorGUILayout.PropertyField( toggleWithKey );
  116. if( toggleWithKey.boolValue )
  117. DrawSubProperty( toggleKey );
  118. EditorGUILayout.Space();
  119. EditorGUILayout.PropertyField( enableSearchbar );
  120. if( enableSearchbar.boolValue )
  121. DrawSubProperty( topSearchbarMinWidth );
  122. EditorGUILayout.PropertyField(copyAllLogsOnResizeButtonClick);
  123. EditorGUILayout.Space();
  124. EditorGUILayout.PropertyField( receiveLogsWhileInactive );
  125. EditorGUILayout.PrefixLabel( receivedLogTypesLabel );
  126. EditorGUI.indentLevel++;
  127. EditorGUILayout.PropertyField( receiveInfoLogs, receiveInfoLogsLabel );
  128. EditorGUILayout.PropertyField( receiveWarningLogs, receiveWarningLogsLabel );
  129. EditorGUILayout.PropertyField( receiveErrorLogs, receiveErrorLogsLabel );
  130. EditorGUILayout.PropertyField( receiveExceptionLogs, receiveExceptionLogsLabel );
  131. EditorGUI.indentLevel--;
  132. EditorGUILayout.PropertyField( receiveLogcatLogsInAndroid );
  133. if( receiveLogcatLogsInAndroid.boolValue )
  134. DrawSubProperty( logcatArguments );
  135. EditorGUILayout.PropertyField( captureLogTimestamps );
  136. if( captureLogTimestamps.boolValue )
  137. DrawSubProperty( alwaysDisplayTimestamps );
  138. EditorGUILayout.PropertyField( maxLogCount );
  139. DrawSubProperty( logsToRemoveAfterMaxLogCount );
  140. EditorGUILayout.PropertyField( queuedLogLimit );
  141. EditorGUILayout.Space();
  142. EditorGUILayout.PropertyField( clearCommandAfterExecution );
  143. EditorGUILayout.PropertyField( commandHistorySize );
  144. EditorGUILayout.PropertyField( showCommandSuggestions );
  145. EditorGUILayout.PropertyField( autoFocusOnCommandInputField );
  146. EditorGUILayout.Space();
  147. DrawPropertiesExcluding( serializedObject, "m_Script" );
  148. serializedObject.ApplyModifiedProperties();
  149. }
  150. private void DrawSubProperty( SerializedProperty property )
  151. {
  152. EditorGUI.indentLevel++;
  153. EditorGUILayout.PropertyField( property );
  154. EditorGUI.indentLevel--;
  155. }
  156. }
  157. }