//关键点的功能菜单 private void ShowKeyframeContextMenu(CustomCurveWrapper animationCurve, int i) { GenericMenu menu = new GenericMenu(); CustomKeyframeWrapper keyframeWrapper = animationCurve.GetKeyframeWrapper(i); KeyframeContext userData = new KeyframeContext(animationCurve, i, keyframeWrapper); Keyframe keyframe = animationCurve.GetKeyframe(i); menu.AddItem(new GUIContent("Delete Key"), false, new GenericMenu.MenuFunction2(this.DeleteKey), userData); menu.AddSeparator(string.Empty); menu.AddItem(new GUIContent("Auto"), animationCurve.IsAuto(i), new GenericMenu.MenuFunction2(this.SetKeyAuto), userData); menu.AddItem(new GUIContent("Free Smooth"), animationCurve.IsFreeSmooth(i), new GenericMenu.MenuFunction2(this.SetKeyFreeSmooth), userData); menu.AddItem(new GUIContent("Flat"), (animationCurve.IsFreeSmooth(i) && (keyframe.inTangent == 0f)) && (keyframe.outTangent == 0f), new GenericMenu.MenuFunction2(this.SetKeyFlat), userData); menu.AddItem(new GUIContent("Broken"), animationCurve.IsBroken(i), new GenericMenu.MenuFunction2(this.SetKeyBroken), userData); menu.AddSeparator(string.Empty); menu.AddItem(new GUIContent("Left Tangent/Free"), animationCurve.IsLeftFree(i), new GenericMenu.MenuFunction2(this.SetKeyLeftFree), userData); menu.AddItem(new GUIContent("Left Tangent/Linear"), animationCurve.IsLeftLinear(i), new GenericMenu.MenuFunction2(this.SetKeyLeftLinear), userData); menu.AddItem(new GUIContent("Left Tangent/Constant"), animationCurve.IsLeftConstant(i), new GenericMenu.MenuFunction2(this.SetKeyLeftConstant), userData); menu.AddItem(new GUIContent("Right Tangent/Free"), animationCurve.IsRightFree(i), new GenericMenu.MenuFunction2(this.SetKeyRightFree), userData); menu.AddItem(new GUIContent("Right Tangent/Linear"), animationCurve.IsRightLinear(i), new GenericMenu.MenuFunction2(this.SetKeyRightLinear), userData); menu.AddItem(new GUIContent("Right Tangent/Constant"), animationCurve.IsRightConstant(i), new GenericMenu.MenuFunction2(this.SetKeyRightConstant), userData); menu.AddItem(new GUIContent("Both Tangents/Free"), animationCurve.IsLeftFree(i) && animationCurve.IsRightFree(i), new GenericMenu.MenuFunction2(this.SetKeyBothFree), userData); menu.AddItem(new GUIContent("Both Tangents/Linear"), animationCurve.IsLeftLinear(i) && animationCurve.IsRightLinear(i), new GenericMenu.MenuFunction2(this.SetKeyBothLinear), userData); menu.AddItem(new GUIContent("Both Tangents/Constant"), animationCurve.IsLeftConstant(i) && animationCurve.IsRightConstant(i), new GenericMenu.MenuFunction2(this.SetKeyBothConstant), userData); menu.ShowAsContext(); }
private void SetKeyBroken(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && !context.curveWrapper.IsRightFree(context.key)) { context.curveWrapper.SetKeyBroken(context.key); } }
private void SetKeyAuto(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && !context.curveWrapper.IsAuto(context.key)) { context.curveWrapper.SetKeyAuto(context.key); } }
private void SetKeyBothConstant(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && (!context.curveWrapper.IsRightConstant(context.key) || !context.curveWrapper.IsLeftConstant(context.key))) { context.curveWrapper.SetKeyLeftConstant(context.key); context.curveWrapper.SetKeyRightConstant(context.key); } }
private void SetKeyFreeSmooth(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && !context.curveWrapper.IsFreeSmooth(context.key)) { //Undo.RecordObject(Wrapper.Behaviour, "Changed Keyframe Tangent Mode"); context.curveWrapper.SetKeyFreeSmooth(context.key); } }
private void SetKeyBothLinear(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && (!context.curveWrapper.IsRightLinear(context.key) || !context.curveWrapper.IsLeftLinear(context.key))) { //Undo.RecordObject(Wrapper.Behaviour, "Changed Keyframe Tangent Mode"); context.curveWrapper.SetKeyLeftLinear(context.key); context.curveWrapper.SetKeyRightLinear(context.key); } }
private void SetKeyRightFree(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && !context.curveWrapper.IsRightFree(context.key)) { //Undo.RecordObject(base.Wrapper.Behaviour, "Changed Keyframe Tangent Mode"); context.curveWrapper.SetKeyRightFree(context.key); //this.haveCurvesChanged = true; //EditorUtility.SetDirty(base.Wrapper.Behaviour); } }
private void SetKeyAuto(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && !context.curveWrapper.IsAuto(context.key)) { foreach (var wrapper in gradient.AnimationCurves) { wrapper.SetKeyAuto(context.key); } } }
private void SetKeyBothFree(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && (!context.curveWrapper.IsRightFree(context.key) || !context.curveWrapper.IsLeftFree(context.key))) { //Undo.RecordObject(Wrapper.Behaviour, "Changed Keyframe Tangent Mode"); context.curveWrapper.SetKeyLeftFree(context.key); context.curveWrapper.SetKeyRightFree(context.key); //EditorUtility.SetDirty(Wrapper.Behaviour); } }
private void SetKeyFlat(object userData) { KeyframeContext context = userData as KeyframeContext; if (context != null) { Keyframe keyframe = context.curveWrapper.GetKeyframe(context.key); if (((keyframe.tangentMode != 0) || (keyframe.inTangent != 0f)) || (keyframe.outTangent != 0f)) { context.curveWrapper.FlattenKey(context.key); } } }
private void SetKeyBothConstant(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && (!context.curveWrapper.IsRightConstant(context.key) || !context.curveWrapper.IsLeftConstant(context.key))) { foreach (var wrapper in gradient.AnimationCurves) { wrapper.SetKeyLeftConstant(context.key); wrapper.SetKeyRightConstant(context.key); } } }
private void SetKeyBroken(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && !context.curveWrapper.IsRightFree(context.key)) { //context.curveWrapper.SetKeyBroken(context.key); foreach (var wrapper in gradient.AnimationCurves) { wrapper.SetKeyBroken(context.key); } } }
private void SetKeyFreeSmooth(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && !context.curveWrapper.IsFreeSmooth(context.key)) { //Undo.RecordObject(Wrapper.Behaviour, "Changed Keyframe Tangent Mode"); //context.curveWrapper.SetKeyFreeSmooth(context.key); foreach (var wrapper in gradient.AnimationCurves) { wrapper.SetKeyFreeSmooth(context.key); } } }
private void SetKeyRightConstant(object userData) { KeyframeContext context = userData as KeyframeContext; if ((context != null) && !context.curveWrapper.IsRightConstant(context.key)) { //Undo.RecordObject(base.Wrapper.Behaviour, "Changed Keyframe Tangent Mode"); foreach (var wrapper in gradient.AnimationCurves) { wrapper.SetKeyRightConstant(context.key); } //this.haveCurvesChanged = true; //EditorUtility.SetDirty(base.Wrapper.Behaviour); } }
private void SetKeyFlat(object userData) { KeyframeContext context = userData as KeyframeContext; if (context != null) { Keyframe keyframe = context.curveWrapper.GetKeyframe(context.key); if (((keyframe.tangentMode != 0) || (keyframe.inTangent != 0f)) || (keyframe.outTangent != 0f)) { foreach (var wrapper in gradient.AnimationCurves) { wrapper.FlattenKey(context.key); } } } }