Hi,
In my editor window there are curve fields and I hold the AnimationCurve values in an array inside the editor class, and a copy inside a ScriptableObject. I tried using Undo.RecordObject on the ScriptableObject but no luck. Currently I am trying SerializedObject and SerializedProperty method, but it is not working. This code adds changes to undo stack but wrong changes, or they become corrupt or something. When I undo more then two moves in curve editor, or try Redo, it looks like it has been done but the result is wrong, Is it an issue with curve fields or am I doing it wrong?
I set the mySerializedObject in the Initialization, with “new SerializedObject( myScriptableObject )”. My code is basicly this:
void OnGUI
{
//........
if(GUI.changed)
{
mySerializedObj.Update();
SerializedProperty p = mySerializedObj.FindProperty(string.Format("animationCurves.Array.data[{0}]", i));
AnimationCurve a = p.animationCurveValue;
a.keys = new Keyframe[animationCurves*.keys.Length];*
animationCurves*.keys.CopyTo(a.keys, 0);*
p.animationCurveValue = a;
obj.ApplyModifiedProperties();
}
//…
}
Thanks in advance.