variables in my own editorwindow will be reset to null when turn to playmode.how to keep it?

private void OnEnable()
{
    _myEditorWindow = new MyEditorWindow();
}

when I open my window in editor mode, those codes will be executed and _myEditorWindow is not null anymore. but when I hit the play btn, OnEnable is executed once more, and what is strange is that _myEditoWindow is null again…
I think this window is reset(reconstructed) when unity switch from editor mode to runtime…
or Do I make some mistakes…
anyone give me some instructions to keep these variables from editor to runtime…

Save the variables in their own class and call from that class when needed. Such as:
You have an EditorWindow for playerStates. You would have a class called PlayerAllStates and an EditorWindow call PlayerStates. In PlayerStates you would get the values of the variables in PlayerAllStates and then set them to what you want.

PlayerAllStates (Get Variable Values) —> PlayerStates
PlayerStates (Set Variable Values) —> PlayerAllStates

Hope this helps!

It’s probably not working. I create a class PlayerAllStates(not derived from any editor class),

public class PlayerAllStates
{
    private static PlayerAllStates _instance;
    public static PlayerAllStates instance
   {
        get { if (_instance == null) _instance = new PlayerAllStates();
        return _instance;
    }
    public string test = "old string";
}

Inside unity, I set PlayerAllStates.instance.test = “new string”,
but when I hit the play button, I set a break and saw that PlayerAllStates.instance.test = “old string”;
It bothers me a lot…
anyway, PlayerAllStates.instance is not null. maybe only static variables are kept…I guess