public static void SetKeyModeFromContext(this AnimationCurve curve, int keyIndex) { Keyframe key = curve [keyIndex]; bool flag = false; if (keyIndex > 0 && curve [keyIndex - 1].GetKeyBroken()) { flag = true; } if (keyIndex < curve.length - 1 && curve [keyIndex + 1].GetKeyBroken()) { flag = true; } key.SetKeyBroken(flag); if (flag) { if (keyIndex > 0) { key.SetKeyTangentMode(0, curve [keyIndex - 1].GetKeyTangentMode(1)); } if (keyIndex < curve.length - 1) { key.SetKeyTangentMode(1, curve [keyIndex + 1].GetKeyTangentMode(0)); } } else { TangentMode mode = TangentMode.Smooth; if (keyIndex > 0 && curve [keyIndex - 1].GetKeyTangentMode(1) != TangentMode.Smooth) { mode = TangentMode.Editable; } if (keyIndex < curve.length - 1 && curve [keyIndex + 1].GetKeyTangentMode(0) != TangentMode.Smooth) { mode = TangentMode.Editable; } key.SetKeyTangentMode(0, mode); key.SetKeyTangentMode(1, mode); } curve.MoveKey(keyIndex, key); }