DebugLogManagerEditor.cs 2.8 KB

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