internal static void SetSmoothEditable(ref Keyframe[] keys)
 {
     for (int i = 0; i < keys.Length; i++)
     {
         CurveUtility.SetKeyBroken(ref keys[i], false);
         CurveUtility.SetKeyTangentMode(ref keys[i], 0, TangentMode.Editable);
         CurveUtility.SetKeyTangentMode(ref keys[i], 1, TangentMode.Editable);
     }
 }
Beispiel #2
0
        public static void SetKeyModeFromContext(AnimationCurve curve, int keyIndex)
        {
            Keyframe key   = curve[keyIndex];
            bool     flag  = false;
            bool     flag2 = false;

            if (keyIndex > 0)
            {
                if (CurveUtility.GetKeyBroken(curve[keyIndex - 1]))
                {
                    flag = true;
                }
                if (CurveUtility.GetKeyTangentMode(curve[keyIndex - 1], 1) == TangentMode.Smooth)
                {
                    flag2 = true;
                }
            }
            if (keyIndex < curve.length - 1)
            {
                if (CurveUtility.GetKeyBroken(curve[keyIndex + 1]))
                {
                    flag = true;
                }
                if (CurveUtility.GetKeyTangentMode(curve[keyIndex + 1], 0) == TangentMode.Smooth)
                {
                    flag2 = true;
                }
            }
            CurveUtility.SetKeyBroken(ref key, flag);
            if (flag && !flag2)
            {
                if (keyIndex > 0)
                {
                    CurveUtility.SetKeyTangentMode(ref key, 0, CurveUtility.GetKeyTangentMode(curve[keyIndex - 1], 1));
                }
                if (keyIndex < curve.length - 1)
                {
                    CurveUtility.SetKeyTangentMode(ref key, 1, CurveUtility.GetKeyTangentMode(curve[keyIndex + 1], 0));
                }
            }
            else
            {
                TangentMode mode = TangentMode.Smooth;
                if (keyIndex > 0 && CurveUtility.GetKeyTangentMode(curve[keyIndex - 1], 1) != TangentMode.Smooth)
                {
                    mode = TangentMode.Editable;
                }
                if (keyIndex < curve.length - 1 && CurveUtility.GetKeyTangentMode(curve[keyIndex + 1], 0) != TangentMode.Smooth)
                {
                    mode = TangentMode.Editable;
                }
                CurveUtility.SetKeyTangentMode(ref key, 0, mode);
                CurveUtility.SetKeyTangentMode(ref key, 1, mode);
            }
            curve.MoveKey(keyIndex, key);
        }
 internal static Keyframe[] GetLinearMirrorKeys()
 {
     Keyframe[] keyframeArray = new Keyframe[] { new Keyframe(0f, 1f, -1f, -1f), new Keyframe(1f, 0f, -1f, -1f) };
     for (int i = 0; i < 2; i++)
     {
         CurveUtility.SetKeyBroken(ref keyframeArray[i], false);
         CurveUtility.SetKeyTangentMode(ref keyframeArray[i], 0, TangentMode.Smooth);
         CurveUtility.SetKeyTangentMode(ref keyframeArray[i], 1, TangentMode.Smooth);
     }
     return(keyframeArray);
 }
Beispiel #4
0
        public void SetTangent(int leftRight, TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <int>          curveIds = new List <int>();
            List <ChangedCurve> curve1   = new List <ChangedCurve>();

            using (List <KeyIdentifier> .Enumerator enumerator = keysToSet.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyIdentifier  current  = enumerator.Current;
                    AnimationCurve curve2   = current.curve;
                    Keyframe       keyframe = current.keyframe;
                    CurveUtility.SetKeyBroken(ref keyframe, true);
                    if (leftRight == 2)
                    {
                        CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
                        CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
                    }
                    else
                    {
                        CurveUtility.SetKeyTangentMode(ref keyframe, leftRight, mode);
                        if (CurveUtility.GetKeyTangentMode(keyframe, 1 - leftRight) == TangentMode.Smooth)
                        {
                            CurveUtility.SetKeyTangentMode(ref keyframe, 1 - leftRight, TangentMode.Editable);
                        }
                    }
                    if (mode == TangentMode.Stepped && (leftRight == 0 || leftRight == 2))
                    {
                        keyframe.inTangent = float.PositiveInfinity;
                    }
                    if (mode == TangentMode.Stepped && (leftRight == 1 || leftRight == 2))
                    {
                        keyframe.outTangent = float.PositiveInfinity;
                    }
                    curve2.MoveKey(current.key, keyframe);
                    CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
                    ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
                    if (!curve1.Contains(changedCurve))
                    {
                        curve1.Add(changedCurve);
                    }
                    curveIds.Add(current.curveId);
                }
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(curve1, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(curveIds, "Set Tangents");
            }
        }
        public void SetTangent(int leftRight, TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <int>          list  = new List <int>();
            List <ChangedCurve> list2 = new List <ChangedCurve>();

            foreach (KeyIdentifier current in keysToSet)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                CurveUtility.SetKeyBroken(ref keyframe, true);
                if (leftRight == 2)
                {
                    CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
                    CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
                }
                else
                {
                    CurveUtility.SetKeyTangentMode(ref keyframe, leftRight, mode);
                    if (CurveUtility.GetKeyTangentMode(keyframe, 1 - leftRight) == TangentMode.Smooth)
                    {
                        CurveUtility.SetKeyTangentMode(ref keyframe, 1 - leftRight, TangentMode.Editable);
                    }
                }
                if (mode == TangentMode.Stepped && (leftRight == 0 || leftRight == 2))
                {
                    keyframe.inTangent = float.PositiveInfinity;
                }
                if (mode == TangentMode.Stepped && (leftRight == 1 || leftRight == 2))
                {
                    keyframe.outTangent = float.PositiveInfinity;
                }
                curve.MoveKey(current.key, keyframe);
                CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                ChangedCurve item = new ChangedCurve(curve, current.binding);
                if (!list2.Contains(item))
                {
                    list2.Add(item);
                }
                list.Add(current.curveId);
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(list2, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(list, "Set Tangents");
            }
        }
 internal static Keyframe[] GetLinearKeys()
 {
     Keyframe[] keyframeArray = new Keyframe[2]
     {
         new Keyframe(0.0f, 0.0f, 1f, 1f),
         new Keyframe(1f, 1f, 1f, 1f)
     };
     for (int index = 0; index < 2; ++index)
     {
         CurveUtility.SetKeyBroken(ref keyframeArray[index], false);
         CurveUtility.SetKeyTangentMode(ref keyframeArray[index], 0, TangentMode.Smooth);
         CurveUtility.SetKeyTangentMode(ref keyframeArray[index], 1, TangentMode.Smooth);
     }
     return(keyframeArray);
 }
Beispiel #7
0
        public void SetBroken(object _keysToSet)
        {
            List <ChangedCurve>  curve1            = new List <ChangedCurve>();
            List <KeyIdentifier> keyIdentifierList = (List <KeyIdentifier>)_keysToSet;
            List <int>           curveIds          = new List <int>();

            using (List <KeyIdentifier> .Enumerator enumerator = keyIdentifierList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyIdentifier  current  = enumerator.Current;
                    AnimationCurve curve2   = current.curve;
                    Keyframe       keyframe = current.keyframe;
                    CurveUtility.SetKeyBroken(ref keyframe, true);
                    if (CurveUtility.GetKeyTangentMode(keyframe, 1) == TangentMode.Smooth)
                    {
                        CurveUtility.SetKeyTangentMode(ref keyframe, 1, TangentMode.Editable);
                    }
                    if (CurveUtility.GetKeyTangentMode(keyframe, 0) == TangentMode.Smooth)
                    {
                        CurveUtility.SetKeyTangentMode(ref keyframe, 0, TangentMode.Editable);
                    }
                    curve2.MoveKey(current.key, keyframe);
                    CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
                    ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
                    if (!curve1.Contains(changedCurve))
                    {
                        curve1.Add(changedCurve);
                    }
                    curveIds.Add(current.curveId);
                }
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(curve1, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(curveIds, "Set Tangents");
            }
        }
Beispiel #8
0
        public void SetBoth(TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> curve1   = new List <ChangedCurve>();
            List <int>          curveIds = new List <int>();

            using (List <KeyIdentifier> .Enumerator enumerator = keysToSet.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyIdentifier  current  = enumerator.Current;
                    AnimationCurve curve2   = current.curve;
                    Keyframe       keyframe = current.keyframe;
                    CurveUtility.SetKeyBroken(ref keyframe, false);
                    CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
                    CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
                    if (mode == TangentMode.Editable)
                    {
                        float smoothTangent = CurveUtility.CalculateSmoothTangent(keyframe);
                        keyframe.inTangent  = smoothTangent;
                        keyframe.outTangent = smoothTangent;
                    }
                    curve2.MoveKey(current.key, keyframe);
                    CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
                    ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
                    if (!curve1.Contains(changedCurve))
                    {
                        curve1.Add(changedCurve);
                    }
                    curveIds.Add(current.curveId);
                }
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(curve1, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(curveIds, "Set Tangents");
            }
        }
        public void SetBoth(TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <int> list = new List <int>();

            foreach (KeyIdentifier current in keysToSet)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                CurveUtility.SetKeyBroken(ref keyframe, false);
                CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
                CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
                if (mode == TangentMode.Editable)
                {
                    float num = CurveUtility.CalculateSmoothTangent(keyframe);
                    keyframe.inTangent  = num;
                    keyframe.outTangent = num;
                }
                curve.MoveKey(current.key, keyframe);
                CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                list.Add(current.curveId);
            }
            this.updater.UpdateCurves(list, "Set Tangents");
        }
        public void SetBroken(object _keysToSet)
        {
            List <ChangedCurve>  list  = new List <ChangedCurve>();
            List <KeyIdentifier> list2 = (List <KeyIdentifier>)_keysToSet;
            List <int>           list3 = new List <int>();

            foreach (KeyIdentifier current in list2)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                CurveUtility.SetKeyBroken(ref keyframe, true);
                if (CurveUtility.GetKeyTangentMode(keyframe, 1) == TangentMode.Smooth)
                {
                    CurveUtility.SetKeyTangentMode(ref keyframe, 1, TangentMode.Editable);
                }
                if (CurveUtility.GetKeyTangentMode(keyframe, 0) == TangentMode.Smooth)
                {
                    CurveUtility.SetKeyTangentMode(ref keyframe, 0, TangentMode.Editable);
                }
                curve.MoveKey(current.key, keyframe);
                CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                ChangedCurve item = new ChangedCurve(curve, current.binding);
                if (!list.Contains(item))
                {
                    list.Add(item);
                }
                list3.Add(current.curveId);
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(list, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(list3, "Set Tangents");
            }
        }
        public void SetBroken(object _keysToSet)
        {
            List <KeyIdentifier> list  = (List <KeyIdentifier>)_keysToSet;
            List <int>           list2 = new List <int>();

            foreach (KeyIdentifier current in list)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                CurveUtility.SetKeyBroken(ref keyframe, true);
                if (CurveUtility.GetKeyTangentMode(keyframe, 1) == TangentMode.Smooth)
                {
                    CurveUtility.SetKeyTangentMode(ref keyframe, 1, TangentMode.Editable);
                }
                if (CurveUtility.GetKeyTangentMode(keyframe, 0) == TangentMode.Smooth)
                {
                    CurveUtility.SetKeyTangentMode(ref keyframe, 0, TangentMode.Editable);
                }
                curve.MoveKey(current.key, keyframe);
                CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                list2.Add(current.curveId);
            }
            this.updater.UpdateCurves(list2, "Set Tangents");
        }
        public void SetBoth(TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> list  = new List <ChangedCurve>();
            List <int>          list2 = new List <int>();

            foreach (KeyIdentifier current in keysToSet)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                CurveUtility.SetKeyBroken(ref keyframe, false);
                CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
                CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
                if (mode == TangentMode.Editable)
                {
                    float num = CurveUtility.CalculateSmoothTangent(keyframe);
                    keyframe.inTangent  = num;
                    keyframe.outTangent = num;
                }
                curve.MoveKey(current.key, keyframe);
                CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                ChangedCurve item = new ChangedCurve(curve, current.binding);
                if (!list.Contains(item))
                {
                    list.Add(item);
                }
                list2.Add(current.curveId);
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(list, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(list2, "Set Tangents");
            }
        }