DebugLogManagerEditor.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 enablePopup;
  10. private SerializedProperty startInPopupMode;
  11. private SerializedProperty startMinimized;
  12. private SerializedProperty toggleWithKey;
  13. private SerializedProperty toggleKey;
  14. private SerializedProperty enableSearchbar;
  15. private SerializedProperty topSearchbarMinWidth;
  16. private SerializedProperty clearCommandAfterExecution;
  17. private SerializedProperty commandHistorySize;
  18. private SerializedProperty showCommandSuggestions;
  19. private SerializedProperty receiveLogcatLogsInAndroid;
  20. private SerializedProperty logcatArguments;
  21. private void OnEnable()
  22. {
  23. singleton = serializedObject.FindProperty( "singleton" );
  24. minimumHeight = serializedObject.FindProperty( "minimumHeight" );
  25. enablePopup = serializedObject.FindProperty( "enablePopup" );
  26. startInPopupMode = serializedObject.FindProperty( "startInPopupMode" );
  27. startMinimized = serializedObject.FindProperty( "startMinimized" );
  28. toggleWithKey = serializedObject.FindProperty( "toggleWithKey" );
  29. toggleKey = serializedObject.FindProperty( "toggleKey" );
  30. enableSearchbar = serializedObject.FindProperty( "enableSearchbar" );
  31. topSearchbarMinWidth = serializedObject.FindProperty( "topSearchbarMinWidth" );
  32. clearCommandAfterExecution = serializedObject.FindProperty( "clearCommandAfterExecution" );
  33. commandHistorySize = serializedObject.FindProperty( "commandHistorySize" );
  34. showCommandSuggestions = serializedObject.FindProperty( "showCommandSuggestions" );
  35. receiveLogcatLogsInAndroid = serializedObject.FindProperty( "receiveLogcatLogsInAndroid" );
  36. logcatArguments = serializedObject.FindProperty( "logcatArguments" );
  37. }
  38. public override void OnInspectorGUI()
  39. {
  40. serializedObject.Update();
  41. EditorGUILayout.PropertyField( singleton );
  42. EditorGUILayout.PropertyField( minimumHeight );
  43. EditorGUILayout.PropertyField( enablePopup );
  44. if( enablePopup.boolValue )
  45. DrawSubProperty( startInPopupMode );
  46. else
  47. DrawSubProperty( startMinimized );
  48. EditorGUILayout.PropertyField( toggleWithKey );
  49. if( toggleWithKey.boolValue )
  50. DrawSubProperty( toggleKey );
  51. EditorGUILayout.PropertyField( enableSearchbar );
  52. if( enableSearchbar.boolValue )
  53. DrawSubProperty( topSearchbarMinWidth );
  54. EditorGUILayout.PropertyField( clearCommandAfterExecution );
  55. EditorGUILayout.PropertyField( commandHistorySize );
  56. EditorGUILayout.PropertyField( showCommandSuggestions );
  57. EditorGUILayout.PropertyField( receiveLogcatLogsInAndroid );
  58. if( receiveLogcatLogsInAndroid.boolValue )
  59. DrawSubProperty( logcatArguments );
  60. DrawPropertiesExcluding( serializedObject, "m_Script" );
  61. serializedObject.ApplyModifiedProperties();
  62. }
  63. private void DrawSubProperty( SerializedProperty property )
  64. {
  65. EditorGUI.indentLevel++;
  66. EditorGUILayout.PropertyField( property );
  67. EditorGUI.indentLevel--;
  68. }
  69. }
  70. }