Sorry, that wasn't the most well constructed question.
From the deserialized animation data - a script on a gameobject.
I sat down with it again with a fresh coffee this morning and worked my way through the Timeline class, figured out that there are RotateTimeline and TranslateTimeline classes extended from CurveTimeLine, which itself is derived from Timeline - none of these are mentioned in the docs or class diagram, so it never occurred to me to look further than CurveTimeLine (and I only came across that because it was required in the Timeline.Remove() method).
While I can script fine in C#, some of the deeper nuances of OO coding are still surfacing so I have to jog in wide circles a lot - Unity's probably to blame for some of that, making life too easy / hiding away a lot of things we really should learn, but end up skipping. Doesn't help much that there are namespace conflicts, and Monodevelop seems happy to suggest things that appear to belong to other classes/types...
So I've got these now anyway, the question is how to remove them gracefully? MonoDevelop suggests Timeline.Remove(CurveTimeline) but I'm getting different results with different approaches and as a result I'm having trouble interpreting the errors (and can't find the declaration for the Timeline.Remove() method).
If I step through all the timelines, I get an error trying to Remove() the first TranslateTimeline. Yet I get no error if I specify the timeline manually (in the code after the foreach).
Even so, in the second case, Remove() hasn't done what I expected - it appears to have just removed the first keyframe of that timeline - my character is still walking, but his Y position leaves off from wherever the previous animation was at.
string anim = "walk-root"; // animation with root motion
int p = 0;
// This throws an InvalidOperatorException Removing timeline[1]*
// "Collection was modified; enumeration operation may not execute."
//
foreach ( CurveTimeline c in skeletonData.FindAnimation(anim).timelines)
{
// reports alternating Rotate/TranslateTimelines
Debug.Log (p + ": " + c.GetType() );
if (c.GetType() == typeof(Spine.TranslateTimeline))
{
Debug.Log ("Removing curve "+p);
skeletonData.FindAnimation(anim).Timelines.Remove(c); // *exception here, p=1
}
p++;
}
// This returns Spline.TranslateTimeline
//
Debug.Log ( skeletonData.FindAnimation(anim).timelines[1].GetType() );
// This needs to be cast explicitly otherwise it returns Spline.Timeline
//
TranslateTimeline timeline = skeletonData.FindAnimation(anim).timelines[1] as TranslateTimeline;
// And this seems to remove only the first keyframe - the root is still moving.
//
skeletonData.FindAnimation(anim).Timelines.Remove(timeline);
[/size]
No doubt I'm making a schoolboy error...?
edit: fixed an oops in my code, same results though.