Custom Editor variable values revert on play/stop?

When I go and run my game, my custom editor values get replaced with the default. I read up about Serializing, but I wasn’t able to piece together what goes where, and I wasn’t able to get this working at all. Could someone point me in the right direction? Here’s a very simplified version of what I’m trying to accomplish. I just want “fakeEditorBool” to persist and affect the value of “fakeBool” in the main script.

This is just the code without any of my attempts at getting it “serialized” or whatever it needs to be. It also resets everything if I modify and save the file.

FakeScript.cs (on one object)

using System.Collections;
using UnityEngine;

public class FakeScript : MonoBehaviour
{
    public bool fakeBool;

    public void Start(){
        if (fakeBool == true){
            Debug.Log("It's happening!");
        }
    }
}

FakeScriptEditor.cs

using UnityEditor;

[CustomEditor(typeof(FakeScript))]
public class FakeScriptEditor : Editor
{
    public bool fakeEditorBool;
    public FakeScript fakeScript;

    public override void OnInspectorGUI(){
        base.OnInspectorGUI();
        fakeScript = (FakeScript)target;

        fakeEditorBool = EditorGUILayout.Toggle("Fake Editor Bool", fakeEditorBool);

        fakeScript.fakeBool = fakeEditorBool;
    }
}

Any help is appreciate, thanks.

The magic sauce you want is called Undo.RecordObject();

Do you mind breaking down what this does and how it helps in layman’s terms?