Im trying to make a script that has a generate button and a checkbox/boolean.
The generate button works fine but the boolean shows but cant be toggled.
What i want is that when the boolean is checked the Console will be cleared but if it isnt checked than it should not the code because the boolean should be false.
GeneratorInspector.cs
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(Generator))]
public class GeneratorInspector : Editor {
bool console = true;
public override void OnInspectorGUI() {
base.OnInspectorGUI();
Generator mygen = (Generator)target;
if(GUILayout.Button("Regenerate")) {
// If clearconsole is ticked
if(console == true) {
// This simply does "LogEntries.Clear()" the long way:
var logEntries = System.Type.GetType("UnityEditorInternal.LogEntries,UnityEditor.dll");
var clearMethod = logEntries.GetMethod("Clear", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
clearMethod.Invoke(null,null);
}
Generator gen = (Generator)target;
gen.GenerateBlocks();
}
console = EditorGUILayout.Toggle("Clear console", true);
}