Hi,
I’m trying to write an editor extension that alters an animation curve via script. Unfortunately, any attempt I make to silently alter the value of the animation clip fails silently.
I first tried using curve.AddKey but this fails to change the value but that failed to change it (no error, just no change), so I tried altering the keyframe directly.
Stepping over the line ’ curve.keys_.value = value;', I can see in the debug watch that ‘curve.keys*.value’ never changes - it’s as if the ‘set’ property method is implemented but does nothing._
void FindOrAddKey(AnimationCurve curve, float time, float value)
_{_
for (int i = 0; i < curve.keys.Length; ++i)
_{_
_if (curve.keys.time == time)
{_
_curve.keys.value = value;
return;
}
}
curve.AddKey(time, value);
}*
My question is if this is intentional or if it’s a bug in Unity? Also, is there another way to edit the curve (I can’t find a way to remove a curve from an animation either - there’s no opposite of ‘AnimationUtility.SetEditorCurve’ as far as I can see.
Thanks for your time._