( Schrödinger's boolean?) custom Editor class OnSceneGUI() and OnInspectorGUI() accessing variable problem!!

Hi, I made a custom editor and it behaves weird.

I created something like this :

[CustomEditor(typeof(MyCustomClass))]
public class MyCustomClassEditor : Editor{
	bool myBool = false;
	
	void OnInspectorGUI(){
		DrawDefaultInspector();
		if(myBool){
			if(GUILayout.Button("Disable")){
				myBool = false;
				//DO SOMETHING
			}
		}else{
			if(GUILayout.Button("Enable")){
				myBool = true;
				//DO SOMETHING
			}
		}
	}
	
	void OnSceneGUI(){
		if(myBool){
			//DRAW SOMETHING ON THE SCENE WINDOW
		}
	}
}

this creates a button in the inspector that toggles the boolean myBool. And it affects the way the OnSceneGUI() behaves.

In fact, it worked without any trouble yesterday, but when I come back for work, it does not work anymore. I tried to figure out what causes the problem, I added a debug script

Debug.Log("Inspector myBool : "+myBool); => OnInspectorGUI()
Debug.Log("Scene myBool : " +myBool); => OnSceneGUI()

and here is what I have found :

From OnInspectorGUI() the value changes with respect to the button click.
But OnSceneGUI() the value is fixed to false. Even if the value from the OnInspectorGUI() is true, OnScenGUI() shows false. and those value exist simultaneously.

What the… is this a Schrödinger’s boolean???

So what I found was, it does not print any statements in the OnSceneGUI until I move my mouse over to the scene view. Once I do that it starts printing the log I have. Then I added a call to SceneView.RepaintAll() and then the log statement inside OnSceneGUI was printed as soon as I clicked the Enable button. Hope this helps!

[CustomEditor(typeof(MyCustomClass))]
public class MyCustomClassEditor : Editor {

    bool myBool = false;

    public override void OnInspectorGUI() {
        DrawDefaultInspector();

        if(myBool){
            if(GUILayout.Button("Disable")){
                myBool = false;
                Logger.Log("Disabled. Bool set to false");
            }
        }else{
            if(GUILayout.Button("Enable")){
                myBool = true;
                Logger.Log("Enabled. Bool set to true");
                SceneView.RepaintAll();
            }
        }
    }

    void OnSceneGUI(){
        if(myBool){
            Logger.Log("ONSCENEGUI : Bool is true");
        }
    }
}