DebugLogManagerEditor.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 enablePopup;
  14. private SerializedProperty startInPopupMode;
  15. private SerializedProperty startMinimized;
  16. private SerializedProperty toggleWithKey;
  17. private SerializedProperty toggleKey;
  18. private SerializedProperty enableSearchbar;
  19. private SerializedProperty topSearchbarMinWidth;
  20. private SerializedProperty receiveLogsWhileInactive;
  21. private SerializedProperty receiveInfoLogs;
  22. private SerializedProperty receiveWarningLogs;
  23. private SerializedProperty receiveErrorLogs;
  24. private SerializedProperty receiveExceptionLogs;
  25. private SerializedProperty captureLogTimestamps;
  26. private SerializedProperty alwaysDisplayTimestamps;
  27. private SerializedProperty queuedLogLimit;
  28. private SerializedProperty clearCommandAfterExecution;
  29. private SerializedProperty commandHistorySize;
  30. private SerializedProperty showCommandSuggestions;
  31. private SerializedProperty receiveLogcatLogsInAndroid;
  32. private SerializedProperty logcatArguments;
  33. private SerializedProperty avoidScreenCutout;
  34. private SerializedProperty autoFocusOnCommandInputField;
  35. 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" );
  36. private readonly GUIContent receiveInfoLogsLabel = new GUIContent( "Info" );
  37. private readonly GUIContent receiveWarningLogsLabel = new GUIContent( "Warning" );
  38. private readonly GUIContent receiveErrorLogsLabel = new GUIContent( "Error" );
  39. private readonly GUIContent receiveExceptionLogsLabel = new GUIContent( "Exception" );
  40. private void OnEnable()
  41. {
  42. singleton = serializedObject.FindProperty( "singleton" );
  43. minimumHeight = serializedObject.FindProperty( "minimumHeight" );
  44. enableHorizontalResizing = serializedObject.FindProperty( "enableHorizontalResizing" );
  45. resizeFromRight = serializedObject.FindProperty( "resizeFromRight" );
  46. minimumWidth = serializedObject.FindProperty( "minimumWidth" );
  47. enablePopup = serializedObject.FindProperty( "enablePopup" );
  48. startInPopupMode = serializedObject.FindProperty( "startInPopupMode" );
  49. startMinimized = serializedObject.FindProperty( "startMinimized" );
  50. toggleWithKey = serializedObject.FindProperty( "toggleWithKey" );
  51. #if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
  52. toggleKey = serializedObject.FindProperty( "toggleBinding" );
  53. #else
  54. toggleKey = serializedObject.FindProperty( "toggleKey" );
  55. #endif
  56. enableSearchbar = serializedObject.FindProperty( "enableSearchbar" );
  57. topSearchbarMinWidth = serializedObject.FindProperty( "topSearchbarMinWidth" );
  58. receiveLogsWhileInactive = serializedObject.FindProperty( "receiveLogsWhileInactive" );
  59. receiveInfoLogs = serializedObject.FindProperty( "receiveInfoLogs" );
  60. receiveWarningLogs = serializedObject.FindProperty( "receiveWarningLogs" );
  61. receiveErrorLogs = serializedObject.FindProperty( "receiveErrorLogs" );
  62. receiveExceptionLogs = serializedObject.FindProperty( "receiveExceptionLogs" );
  63. captureLogTimestamps = serializedObject.FindProperty( "captureLogTimestamps" );
  64. alwaysDisplayTimestamps = serializedObject.FindProperty( "alwaysDisplayTimestamps" );
  65. queuedLogLimit = serializedObject.FindProperty( "queuedLogLimit" );
  66. clearCommandAfterExecution = serializedObject.FindProperty( "clearCommandAfterExecution" );
  67. commandHistorySize = serializedObject.FindProperty( "commandHistorySize" );
  68. showCommandSuggestions = serializedObject.FindProperty( "showCommandSuggestions" );
  69. receiveLogcatLogsInAndroid = serializedObject.FindProperty( "receiveLogcatLogsInAndroid" );
  70. logcatArguments = serializedObject.FindProperty( "logcatArguments" );
  71. avoidScreenCutout = serializedObject.FindProperty( "avoidScreenCutout" );
  72. autoFocusOnCommandInputField = serializedObject.FindProperty( "autoFocusOnCommandInputField" );
  73. }
  74. public override void OnInspectorGUI()
  75. {
  76. serializedObject.Update();
  77. EditorGUILayout.PropertyField( singleton );
  78. EditorGUILayout.Space();
  79. EditorGUILayout.PropertyField( minimumHeight );
  80. EditorGUILayout.PropertyField( enableHorizontalResizing );
  81. if( enableHorizontalResizing.boolValue )
  82. {
  83. DrawSubProperty( resizeFromRight );
  84. DrawSubProperty( minimumWidth );
  85. }
  86. EditorGUILayout.PropertyField( avoidScreenCutout );
  87. EditorGUILayout.Space();
  88. EditorGUILayout.PropertyField( enablePopup );
  89. if( enablePopup.boolValue )
  90. DrawSubProperty( startInPopupMode );
  91. else
  92. DrawSubProperty( startMinimized );
  93. EditorGUILayout.PropertyField( toggleWithKey );
  94. if( toggleWithKey.boolValue )
  95. DrawSubProperty( toggleKey );
  96. EditorGUILayout.Space();
  97. EditorGUILayout.PropertyField( enableSearchbar );
  98. if( enableSearchbar.boolValue )
  99. DrawSubProperty( topSearchbarMinWidth );
  100. EditorGUILayout.Space();
  101. EditorGUILayout.PropertyField( receiveLogsWhileInactive );
  102. EditorGUILayout.PrefixLabel( receivedLogTypesLabel );
  103. EditorGUI.indentLevel++;
  104. EditorGUILayout.PropertyField( receiveInfoLogs, receiveInfoLogsLabel );
  105. EditorGUILayout.PropertyField( receiveWarningLogs, receiveWarningLogsLabel );
  106. EditorGUILayout.PropertyField( receiveErrorLogs, receiveErrorLogsLabel );
  107. EditorGUILayout.PropertyField( receiveExceptionLogs, receiveExceptionLogsLabel );
  108. EditorGUI.indentLevel--;
  109. EditorGUILayout.PropertyField( receiveLogcatLogsInAndroid );
  110. if( receiveLogcatLogsInAndroid.boolValue )
  111. DrawSubProperty( logcatArguments );
  112. EditorGUILayout.PropertyField( captureLogTimestamps );
  113. if( captureLogTimestamps.boolValue )
  114. DrawSubProperty( alwaysDisplayTimestamps );
  115. EditorGUILayout.PropertyField( queuedLogLimit );
  116. EditorGUILayout.Space();
  117. EditorGUILayout.PropertyField( clearCommandAfterExecution );
  118. EditorGUILayout.PropertyField( commandHistorySize );
  119. EditorGUILayout.PropertyField( showCommandSuggestions );
  120. EditorGUILayout.PropertyField( autoFocusOnCommandInputField );
  121. EditorGUILayout.Space();
  122. DrawPropertiesExcluding( serializedObject, "m_Script" );
  123. serializedObject.ApplyModifiedProperties();
  124. }
  125. private void DrawSubProperty( SerializedProperty property )
  126. {
  127. EditorGUI.indentLevel++;
  128. EditorGUILayout.PropertyField( property );
  129. EditorGUI.indentLevel--;
  130. }
  131. }
  132. }