How do you emulate the undo system with custom inspectors?

In the Unity Editor, any changes you make in the default Inspectors can be undone, nicely. I want to do this with custom inspectors too. I'd just like any code example; I didn't have luck with whatever I tried last time.

What did you do last time? I've successfully used features of the Undo class in inspectors in the past. What you're attempting to undo influences how I'd recommend you use it (and any code samples I could offer), but the class documentation is robust enough to tell you when to use RegisterUndo and RegisterSnapshot. If that's what you were using before, be sure to let everyone know and maybe someone can come up with an alternate solution.

ETA: Here's an example of how I've used Undo.RegisterUndo in an inspector before:

GameObject tempObject = (GameObject)EditorGUILayout.ObjectField (((MyClass)target).myObject, typeof(GameObject));
if (tempObject != ((MyClass)target).myObject)
    Undo.RegisterUndo (new Object[1] { target }, "Set Object");
    ((MyClass)target).myObject = tempObject;
} Does that help?