How to restore EditorWindow property after playmode?

I just started experimenting with a custom EditorWindow and I added a simple toggle button to enable/disable MeshRenderer.enable. Everything works just fine, however, after returning from playmode, the state of the button still persists. I thought everything got serialized and restored when returning to Edit mode? At least that’s what happened to the MeshRenderer.enable. How can I restore the state of the toggle button pre-Playmode so everything is in sync?

Here’s the sample:

public class TestEditor : EditorWindow
{
    private bool EnableButton = true;

    void OnGUI()
    {
        EnableButton = EditorGUILayout.Toggle("ToggleMesh", EnableButton);
        dosomething();
    }
}

EditorWindows are serialized the same way all other objects are serialized. That means only public variables (or private variables with SerializeField) of a serializable type are “saved” and “restored”. Another way is to use OnEnable / OnDisable and EditorPrefs to store information even beyond editor restarts.