DebugLogManagerEditor.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using UnityEditor;
  2. namespace IngameDebugConsole
  3. {
  4. [CustomEditor( typeof( DebugLogManager ) )]
  5. public class DebugLogManagerEditor : Editor
  6. {
  7. private SerializedProperty singleton;
  8. private SerializedProperty minimumHeight;
  9. private SerializedProperty enableHorizontalResizing;
  10. private SerializedProperty resizeFromRight;
  11. private SerializedProperty minimumWidth;
  12. private SerializedProperty enablePopup;
  13. private SerializedProperty startInPopupMode;
  14. private SerializedProperty startMinimized;
  15. private SerializedProperty toggleWithKey;
  16. private SerializedProperty toggleKey;
  17. private SerializedProperty enableSearchbar;
  18. private SerializedProperty topSearchbarMinWidth;
  19. private SerializedProperty captureLogTimestamps;
  20. private SerializedProperty alwaysDisplayTimestamps;
  21. private SerializedProperty clearCommandAfterExecution;
  22. private SerializedProperty commandHistorySize;
  23. private SerializedProperty showCommandSuggestions;
  24. private SerializedProperty receiveLogcatLogsInAndroid;
  25. private SerializedProperty logcatArguments;
  26. private void OnEnable()
  27. {
  28. singleton = serializedObject.FindProperty( "singleton" );
  29. minimumHeight = serializedObject.FindProperty( "minimumHeight" );
  30. enableHorizontalResizing = serializedObject.FindProperty( "enableHorizontalResizing" );
  31. resizeFromRight = serializedObject.FindProperty( "resizeFromRight" );
  32. minimumWidth = serializedObject.FindProperty( "minimumWidth" );
  33. enablePopup = serializedObject.FindProperty( "enablePopup" );
  34. startInPopupMode = serializedObject.FindProperty( "startInPopupMode" );
  35. startMinimized = serializedObject.FindProperty( "startMinimized" );
  36. toggleWithKey = serializedObject.FindProperty( "toggleWithKey" );
  37. #if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
  38. toggleKey = serializedObject.FindProperty( "toggleBinding" );
  39. #else
  40. toggleKey = serializedObject.FindProperty( "toggleKey" );
  41. #endif
  42. enableSearchbar = serializedObject.FindProperty( "enableSearchbar" );
  43. topSearchbarMinWidth = serializedObject.FindProperty( "topSearchbarMinWidth" );
  44. captureLogTimestamps = serializedObject.FindProperty( "captureLogTimestamps" );
  45. alwaysDisplayTimestamps = serializedObject.FindProperty( "alwaysDisplayTimestamps" );
  46. clearCommandAfterExecution = serializedObject.FindProperty( "clearCommandAfterExecution" );
  47. commandHistorySize = serializedObject.FindProperty( "commandHistorySize" );
  48. showCommandSuggestions = serializedObject.FindProperty( "showCommandSuggestions" );
  49. receiveLogcatLogsInAndroid = serializedObject.FindProperty( "receiveLogcatLogsInAndroid" );
  50. logcatArguments = serializedObject.FindProperty( "logcatArguments" );
  51. }
  52. public override void OnInspectorGUI()
  53. {
  54. serializedObject.Update();
  55. EditorGUILayout.PropertyField( singleton );
  56. EditorGUILayout.PropertyField( minimumHeight );
  57. EditorGUILayout.PropertyField( enableHorizontalResizing );
  58. if( enableHorizontalResizing.boolValue )
  59. {
  60. DrawSubProperty( resizeFromRight );
  61. DrawSubProperty( minimumWidth );
  62. }
  63. EditorGUILayout.PropertyField( enablePopup );
  64. if( enablePopup.boolValue )
  65. DrawSubProperty( startInPopupMode );
  66. else
  67. DrawSubProperty( startMinimized );
  68. EditorGUILayout.PropertyField( toggleWithKey );
  69. if( toggleWithKey.boolValue )
  70. DrawSubProperty( toggleKey );
  71. EditorGUILayout.PropertyField( enableSearchbar );
  72. if( enableSearchbar.boolValue )
  73. DrawSubProperty( topSearchbarMinWidth );
  74. EditorGUILayout.PropertyField( captureLogTimestamps );
  75. if( captureLogTimestamps.boolValue )
  76. DrawSubProperty( alwaysDisplayTimestamps );
  77. EditorGUILayout.PropertyField( clearCommandAfterExecution );
  78. EditorGUILayout.PropertyField( commandHistorySize );
  79. EditorGUILayout.PropertyField( showCommandSuggestions );
  80. EditorGUILayout.PropertyField( receiveLogcatLogsInAndroid );
  81. if( receiveLogcatLogsInAndroid.boolValue )
  82. DrawSubProperty( logcatArguments );
  83. DrawPropertiesExcluding( serializedObject, "m_Script" );
  84. serializedObject.ApplyModifiedProperties();
  85. }
  86. private void DrawSubProperty( SerializedProperty property )
  87. {
  88. EditorGUI.indentLevel++;
  89. EditorGUILayout.PropertyField( property );
  90. EditorGUI.indentLevel--;
  91. }
  92. }
  93. }