How do you save variable values in custom Editors?

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

You may edit your post above.

The set dirty should work, but another option is always Undo.RecordObject().