public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve curve, object value, Type type, AnimationKeyTime time) { AnimationWindowKeyframe animationWindowKeyframe = curve.FindKeyAtTime(time); AnimationWindowKeyframe result; if (animationWindowKeyframe != null) { animationWindowKeyframe.value = value; result = animationWindowKeyframe; } else { AnimationWindowKeyframe animationWindowKeyframe2 = null; if (curve.isPPtrCurve) { animationWindowKeyframe2 = new AnimationWindowKeyframe(); animationWindowKeyframe2.time = time.time; animationWindowKeyframe2.value = value; animationWindowKeyframe2.curve = curve; curve.AddKeyframe(animationWindowKeyframe2, time); } else if (type == typeof(bool) || type == typeof(float)) { animationWindowKeyframe2 = new AnimationWindowKeyframe(); AnimationCurve animationCurve = curve.ToAnimationCurve(); Keyframe key = new Keyframe(time.time, (float)value); if (type == typeof(bool)) { AnimationUtility.SetKeyLeftTangentMode(ref key, AnimationUtility.TangentMode.Constant); AnimationUtility.SetKeyRightTangentMode(ref key, AnimationUtility.TangentMode.Constant); AnimationUtility.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.time = time.time; animationWindowKeyframe2.value = value; animationWindowKeyframe2.curve = curve; curve.AddKeyframe(animationWindowKeyframe2, time); } result = animationWindowKeyframe2; } return(result); }
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); }