How do You Record Changes to Sub-Objects with Undo?

I’m working on a tool that works on data of a structure that I’ve defined. Broadly that structure looks like:

OuterObj : ScriptableObject  
    List[InnerObj : ScriptableObject]  
        List[DataObj : System.Object]

So there is a single ScriptableObject that maintains a list of another type of ScriptableObjects, which maintains a list of System.Object objects. Specifically, the DataObj class above contains an AnimationCurve object.

The tool I am working on separately maintains a reference to the OuterObj, a single InnerObj (from within the OuterObj’s list), and a single DataObj (from within the InnerObj’s list). I have attempted to do something like:

AnimationCurve outputCurve = EditorGUILayout.CurveField(“Curve”, selectedDataObj.CurveData);
if (EditorGUI.EndChangeCheck())
Undo.RecordObject(selectedInnerObj, “Modify Event Curve”);
selectedDataObj.CurveData = outputCurve;

This only appears to work part of the time. The changes actually occur on the curve, sure, but the Undo field doesn’t always update. And when it does, actually committing the Undo action doesn’t appear to affect the curve data.

Any thoughts on what I’m doing wrong? Does anyone know how to properly Detect and Register a CurveField change on an object?

you can use this pulgin for Recording 3D objects with its children… by enabling one simple flag. Easy to use and program. check out the demo. Unity Asset Store - The Best Assets for Game Making


Unfortunately, GameRec is no longer available.