public void LeftKeyframeTangentLinear(USInternalKeyframe keyframe) { USUndoManager.PropertyChange(keyframe, "Left Tangent Linear"); keyframe.LeftTangentLinear(); }
private USInternalKeyframe AddKeyframe(USInternalCurve curve, float time, float value) { // If a keyframe already exists at this time, use that one. USInternalKeyframe internalKeyframe = null; foreach (var keyframe in curve.Keys) { if (Mathf.Approximately(keyframe.Time, time)) { internalKeyframe = keyframe; } if (internalKeyframe != null) { break; } } // Didn't find a keyframe create a new one. if (!internalKeyframe) { internalKeyframe = CreateInstance <USInternalKeyframe>(); USUndoManager.RegisterCreatedObjectUndo(internalKeyframe, "Add New Keyframe"); USUndoManager.RegisterCompleteObjectUndo(curve, "Add Keyframe"); curve.Keys.Add(internalKeyframe); } USUndoManager.RegisterCompleteObjectUndo(internalKeyframe, "Add Keyframe"); internalKeyframe.curve = curve; internalKeyframe.Time = time; internalKeyframe.Value = value; internalKeyframe.InTangent = 0.0f; internalKeyframe.OutTangent = 0.0f; if (AutoTangentMode == CurveAutoTangentModes.Smooth) { internalKeyframe.Smooth(); } else if (AutoTangentMode == CurveAutoTangentModes.Flatten) { internalKeyframe.Flatten(); } else if (AutoTangentMode == CurveAutoTangentModes.RightLinear) { internalKeyframe.RightTangentLinear(); } else if (AutoTangentMode == CurveAutoTangentModes.RightConstant) { internalKeyframe.RightTangentConstant(); } else if (AutoTangentMode == CurveAutoTangentModes.LeftLinear) { internalKeyframe.LeftTangentLinear(); } else if (AutoTangentMode == CurveAutoTangentModes.LeftConstant) { internalKeyframe.LeftTangentConstant(); } else if (AutoTangentMode == CurveAutoTangentModes.BothLinear) { internalKeyframe.BothTangentLinear(); } else if (AutoTangentMode == CurveAutoTangentModes.BothConstant) { internalKeyframe.BothTangentConstant(); } curve.Keys.Sort(USInternalCurve.KeyframeComparer); curve.BuildAnimationCurveFromInternalCurve(); return(internalKeyframe); }