private void SetTangent(int leftRight, Skill.Editor.CurveUtility.TangentMode mode) { if (Selection.Count > 0) { foreach (CurveKey ki in Selection) { Keyframe key = ki.Keyframe; CurveUtility.SetKeyBroken(ref key, true); if (leftRight == 2) { CurveUtility.SetKeyTangentMode(ref key, 0, mode); CurveUtility.SetKeyTangentMode(ref key, 1, mode); } else { CurveUtility.SetKeyTangentMode(ref key, leftRight, mode); if (CurveUtility.GetKeyTangentMode(key, 1 - leftRight) == CurveUtility.TangentMode.Smooth) { CurveUtility.SetKeyTangentMode(ref key, 1 - leftRight, CurveUtility.TangentMode.Editable); } } if ((mode == CurveUtility.TangentMode.Stepped) && ((leftRight == 0) || (leftRight == 2))) { key.inTangent = float.PositiveInfinity; } if ((mode == CurveUtility.TangentMode.Stepped) && ((leftRight == 1) || (leftRight == 2))) { key.outTangent = float.PositiveInfinity; } ki.Curve.MoveKey(ki.Index, key); CurveUtility.UpdateTangentsFromModeSurrounding(ki.Curve, ki.Index); } } }
public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve curve, object value, Type type, AnimationKeyTime time) { AnimationWindowKeyframe animationWindowKeyframe = curve.FindKeyAtTime(time); if (animationWindowKeyframe != null) { animationWindowKeyframe.value = value; return(animationWindowKeyframe); } AnimationWindowKeyframe animationWindowKeyframe2 = new AnimationWindowKeyframe(); animationWindowKeyframe2.time = time.time; if (curve.isPPtrCurve) { animationWindowKeyframe2.value = value; animationWindowKeyframe2.curve = curve; curve.AddKeyframe(animationWindowKeyframe2, time); } else { if (type == typeof(bool) || type == typeof(float)) { AnimationCurve animationCurve = curve.ToAnimationCurve(); Keyframe key = new Keyframe(time.time, (float)value); if (type == typeof(bool)) { CurveUtility.SetKeyTangentMode(ref key, 0, TangentMode.Stepped); CurveUtility.SetKeyTangentMode(ref key, 1, TangentMode.Stepped); CurveUtility.SetKeyBroken(ref key, true); animationWindowKeyframe2.m_TangentMode = key.tangentMode; animationWindowKeyframe2.m_InTangent = float.PositiveInfinity; animationWindowKeyframe2.m_OutTangent = float.PositiveInfinity; } else { int num = animationCurve.AddKey(key); if (num != -1) { CurveUtility.SetKeyModeFromContext(animationCurve, num); animationWindowKeyframe2.m_TangentMode = animationCurve[num].tangentMode; } } animationWindowKeyframe2.value = value; animationWindowKeyframe2.curve = curve; curve.AddKeyframe(animationWindowKeyframe2, time); } } return(animationWindowKeyframe2); }
public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve curve, object value, Type type, AnimationKeyTime time) { AnimationWindowKeyframe keyframe = curve.FindKeyAtTime(time); if (keyframe != null) { keyframe.value = value; return(keyframe); } AnimationWindowKeyframe key = new AnimationWindowKeyframe { time = time.time }; if (curve.isPPtrCurve) { key.value = value; key.curve = curve; curve.AddKeyframe(key, time); return(key); } if ((type == typeof(bool)) || (type == typeof(float))) { AnimationCurve curve2 = curve.ToAnimationCurve(); Keyframe keyframe3 = new Keyframe(time.time, (float)value); if (type == typeof(bool)) { CurveUtility.SetKeyTangentMode(ref keyframe3, 0, TangentMode.Stepped); CurveUtility.SetKeyTangentMode(ref keyframe3, 1, TangentMode.Stepped); CurveUtility.SetKeyBroken(ref keyframe3, true); key.m_TangentMode = keyframe3.tangentMode; key.m_InTangent = float.PositiveInfinity; key.m_OutTangent = float.PositiveInfinity; } else { int keyIndex = curve2.AddKey(keyframe3); if (keyIndex != -1) { CurveUtility.SetKeyModeFromContext(curve2, keyIndex); Keyframe keyframe4 = curve2[keyIndex]; key.m_TangentMode = keyframe4.tangentMode; } } key.value = value; key.curve = curve; curve.AddKeyframe(key, time); } return(key); }
public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve curve, object value, System.Type type, AnimationKeyTime time) { AnimationWindowKeyframe keyAtTime = curve.FindKeyAtTime(time); if (keyAtTime != null) { keyAtTime.value = value; return(keyAtTime); } AnimationWindowKeyframe key1 = new AnimationWindowKeyframe(); key1.time = time.time; if (curve.isPPtrCurve) { key1.value = value; key1.curve = curve; curve.AddKeyframe(key1, time); } else if (type == typeof(bool) || type == typeof(float)) { AnimationCurve animationCurve = curve.ToAnimationCurve(); Keyframe key2 = new Keyframe(time.time, (float)value); if (type == typeof(bool)) { CurveUtility.SetKeyTangentMode(ref key2, 0, TangentMode.Stepped); CurveUtility.SetKeyTangentMode(ref key2, 1, TangentMode.Stepped); CurveUtility.SetKeyBroken(ref key2, true); key1.m_TangentMode = key2.tangentMode; key1.m_InTangent = float.PositiveInfinity; key1.m_OutTangent = float.PositiveInfinity; } else { int keyIndex = animationCurve.AddKey(key2); if (keyIndex != -1) { CurveUtility.SetKeyModeFromContext(animationCurve, keyIndex); key1.m_TangentMode = animationCurve[keyIndex].tangentMode; } } key1.value = value; key1.curve = curve; curve.AddKeyframe(key1, time); } return(key1); }
public void SetBroken() { if (Selection.Count > 0) { foreach (CurveKey ki in Selection) { Keyframe key = ki.Keyframe; CurveUtility.SetKeyBroken(ref key, true); if (CurveUtility.GetKeyTangentMode(key, 1) == CurveUtility.TangentMode.Smooth) { CurveUtility.SetKeyTangentMode(ref key, 1, CurveUtility.TangentMode.Editable); } if (CurveUtility.GetKeyTangentMode(key, 0) == CurveUtility.TangentMode.Smooth) { CurveUtility.SetKeyTangentMode(ref key, 0, CurveUtility.TangentMode.Editable); } ki.Curve.MoveKey(ki.Index, key); CurveUtility.UpdateTangentsFromModeSurrounding(ki.Curve, ki.Index); } } }