DebugLogManagerEditor.cs 2.3 KB

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