示例#1
0
    //关键点的功能菜单
    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();
    }
示例#2
0
    private void SetKeyBroken(object userData)
    {
        KeyframeContext context = userData as KeyframeContext;

        if ((context != null) && !context.curveWrapper.IsRightFree(context.key))
        {
            context.curveWrapper.SetKeyBroken(context.key);
        }
    }
示例#3
0
    private void SetKeyAuto(object userData)
    {
        KeyframeContext context = userData as KeyframeContext;

        if ((context != null) && !context.curveWrapper.IsAuto(context.key))
        {
            context.curveWrapper.SetKeyAuto(context.key);
        }
    }
示例#4
0
    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);
        }
    }
示例#5
0
    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);
        }
    }
示例#6
0
    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);
        }
    }
示例#7
0
    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);
        }
    }
示例#8
0
    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);
            }
        }
    }
示例#9
0
    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);
        }
    }
示例#10
0
    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);
            }
        }
    }
示例#11
0
    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);
            }
        }
    }
示例#12
0
    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);
            }
        }
    }
示例#13
0
    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);
            }
        }
    }
示例#14
0
    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);
        }
    }
示例#15
0
    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);
                }
            }
        }
    }