コード例 #1
0
        public void UpdateTangentsFromMode(int index, int componentIndex)
        {
            AnimationCurve curve = this.GetCurve(componentIndex);

            if ((index >= 0) && (index < curve.length))
            {
                Keyframe key = curve[index];
                if ((CurveUtility.GetKeyTangentMode(key, 0) == TangentMode.Linear) && (index >= 1))
                {
                    key.inTangent = this.CalculateLinearTangent(index, index - 1, componentIndex);
                    curve.MoveKey(index, key);
                }
                if ((CurveUtility.GetKeyTangentMode(key, 1) == TangentMode.Linear) && ((index + 1) < curve.length))
                {
                    key.outTangent = this.CalculateLinearTangent(index, index + 1, componentIndex);
                    curve.MoveKey(index, key);
                }
                if ((CurveUtility.GetKeyTangentMode(key, 0) == TangentMode.Smooth) || (CurveUtility.GetKeyTangentMode(key, 1) == TangentMode.Smooth))
                {
                    float num = this.CalculateSmoothTangent(index, componentIndex);
                    key.outTangent = num;
                    key.inTangent  = num;
                    curve.MoveKey(index, key);
                }
            }
        }
コード例 #2
0
ファイル: CurveUtility.cs プロジェクト: wensincai/Unity5.4
        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);
        }
コード例 #3
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");
            }
        }
コード例 #4
0
        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");
            }
        }
コード例 #5
0
 public static void SetKeyTangentMode(ref Keyframe key, int leftRight, TangentMode mode)
 {
     if (leftRight == 0)
     {
         key.tangentMode &= -7;
         key.tangentMode |= (int)((int)mode << 1);
     }
     else
     {
         key.tangentMode &= -25;
         key.tangentMode |= (int)((int)mode << 3);
     }
     if (CurveUtility.GetKeyTangentMode(key, leftRight) != mode)
     {
         Debug.Log("bug");
     }
 }
コード例 #6
0
 public static void SetKeyTangentMode(ref Keyframe key, int leftRight, TangentMode mode)
 {
     if (leftRight == 0)
     {
         key.tangentMode &= -7;
         key.tangentMode |= (int)mode << 1;
     }
     else
     {
         key.tangentMode &= -25;
         key.tangentMode |= (int)mode << 3;
     }
     if (CurveUtility.GetKeyTangentMode(key, leftRight) == mode)
     {
         return;
     }
     Debug.Log((object)"bug");
 }
コード例 #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");
            }
        }
コード例 #8
0
        private static void UpdateTangentsFromMode(AnimationCurve curve, int index)
        {
            if (index < 0 || index >= curve.length)
            {
                return;
            }
            Keyframe key = curve[index];

            if (CurveUtility.GetKeyTangentMode(key, 0) == TangentMode.Linear && index >= 1)
            {
                key.inTangent = CurveUtility.CalculateLinearTangent(curve, index, index - 1);
                curve.MoveKey(index, key);
            }
            if (CurveUtility.GetKeyTangentMode(key, 1) == TangentMode.Linear && index + 1 < curve.length)
            {
                key.outTangent = CurveUtility.CalculateLinearTangent(curve, index, index + 1);
                curve.MoveKey(index, key);
            }
            if (CurveUtility.GetKeyTangentMode(key, 0) == TangentMode.Smooth || CurveUtility.GetKeyTangentMode(key, 1) == TangentMode.Smooth)
            {
                curve.SmoothTangents(index, 0f);
            }
        }
コード例 #9
0
        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");
            }
        }
コード例 #10
0
        public void UpdateTangentsFromMode(int index, int componentIndex)
        {
            AnimationCurve curve = this.GetCurve(componentIndex);

            if (index < 0 || index >= curve.length)
            {
                return;
            }
            Keyframe key = curve[index];

            if (CurveUtility.GetKeyTangentMode(key, 0) == TangentMode.Linear && index >= 1)
            {
                key.inTangent = this.CalculateLinearTangent(index, index - 1, componentIndex);
                curve.MoveKey(index, key);
            }
            if (CurveUtility.GetKeyTangentMode(key, 1) == TangentMode.Linear && index + 1 < curve.length)
            {
                key.outTangent = this.CalculateLinearTangent(index, index + 1, componentIndex);
                curve.MoveKey(index, key);
            }
            if (CurveUtility.GetKeyTangentMode(key, 0) != TangentMode.Smooth && CurveUtility.GetKeyTangentMode(key, 1) != TangentMode.Smooth)
            {
                return;
            }
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Keyframe& local         = @key;
            float     smoothTangent = this.CalculateSmoothTangent(index, componentIndex);

            key.outTangent = smoothTangent;
            double num = (double)smoothTangent;

            // ISSUE: explicit reference operation
            (^ local).inTangent = (float)num;
            curve.MoveKey(index, key);
        }
コード例 #11
0
        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");
        }
コード例 #12
0
        public void AddTangentMenuItems(GenericMenu menu, List <KeyIdentifier> keyList)
        {
            bool flag  = keyList.Count > 0;
            bool on    = flag;
            bool on2   = flag;
            bool on3   = flag;
            bool on4   = flag;
            bool flag2 = flag;
            bool flag3 = flag;
            bool flag4 = flag;
            bool flag5 = flag;
            bool flag6 = flag;
            bool flag7 = flag;

            foreach (KeyIdentifier current in keyList)
            {
                Keyframe    keyframe        = current.keyframe;
                TangentMode keyTangentMode  = CurveUtility.GetKeyTangentMode(keyframe, 0);
                TangentMode keyTangentMode2 = CurveUtility.GetKeyTangentMode(keyframe, 1);
                bool        keyBroken       = CurveUtility.GetKeyBroken(keyframe);
                if (keyTangentMode != TangentMode.Smooth || keyTangentMode2 != TangentMode.Smooth)
                {
                    on = false;
                }
                if (keyBroken || keyTangentMode != TangentMode.Editable || keyTangentMode2 != TangentMode.Editable)
                {
                    on2 = false;
                }
                if (keyBroken || keyTangentMode != TangentMode.Editable || keyframe.inTangent != 0f || keyTangentMode2 != TangentMode.Editable || keyframe.outTangent != 0f)
                {
                    on3 = false;
                }
                if (!keyBroken)
                {
                    on4 = false;
                }
                if (!keyBroken || keyTangentMode != TangentMode.Editable)
                {
                    flag2 = false;
                }
                if (!keyBroken || keyTangentMode != TangentMode.Linear)
                {
                    flag3 = false;
                }
                if (!keyBroken || keyTangentMode != TangentMode.Stepped)
                {
                    flag4 = false;
                }
                if (!keyBroken || keyTangentMode2 != TangentMode.Editable)
                {
                    flag5 = false;
                }
                if (!keyBroken || keyTangentMode2 != TangentMode.Linear)
                {
                    flag6 = false;
                }
                if (!keyBroken || keyTangentMode2 != TangentMode.Stepped)
                {
                    flag7 = false;
                }
            }
            if (flag)
            {
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupAuto"), on, new GenericMenu.MenuFunction2(this.SetSmooth), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupFreeSmooth"), on2, new GenericMenu.MenuFunction2(this.SetEditable), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupFlat"), on3, new GenericMenu.MenuFunction2(this.SetFlat), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupBroken"), on4, new GenericMenu.MenuFunction2(this.SetBroken), keyList);
                menu.AddSeparator(string.Empty);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupLeftTangent/Free"), flag2, new GenericMenu.MenuFunction2(this.SetLeftEditable), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupLeftTangent/Linear"), flag3, new GenericMenu.MenuFunction2(this.SetLeftLinear), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupLeftTangent/Constant"), flag4, new GenericMenu.MenuFunction2(this.SetLeftConstant), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupRightTangent/Free"), flag5, new GenericMenu.MenuFunction2(this.SetRightEditable), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupRightTangent/Linear"), flag6, new GenericMenu.MenuFunction2(this.SetRightLinear), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupRightTangent/Constant"), flag7, new GenericMenu.MenuFunction2(this.SetRightConstant), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupBothTangents/Free"), flag5 && flag2, new GenericMenu.MenuFunction2(this.SetBothEditable), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupBothTangents/Linear"), flag6 && flag3, new GenericMenu.MenuFunction2(this.SetBothLinear), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("CurveKeyPopupBothTangents/Constant"), flag7 && flag4, new GenericMenu.MenuFunction2(this.SetBothConstant), keyList);
            }
            else
            {
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupAuto"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupFreeSmooth"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupFlat"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupBroken"));
                menu.AddSeparator(string.Empty);
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupLeftTangent/Free"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupLeftTangent/Linear"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupLeftTangent/Constant"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupRightTangent/Free"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupRightTangent/Linear"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupRightTangent/Constant"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupBothTangents/Free"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupBothTangents/Linear"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("CurveKeyPopupBothTangents/Constant"));
            }
        }
コード例 #13
0
        public void AddTangentMenuItems(GenericMenu menu, List <KeyIdentifier> keyList)
        {
            bool flag   = keyList.Count > 0;
            bool on     = flag;
            bool flag3  = flag;
            bool flag4  = flag;
            bool flag5  = flag;
            bool flag6  = flag;
            bool flag7  = flag;
            bool flag8  = flag;
            bool flag9  = flag;
            bool flag10 = flag;
            bool flag11 = flag;

            foreach (KeyIdentifier identifier in keyList)
            {
                Keyframe    key            = identifier.keyframe;
                TangentMode keyTangentMode = CurveUtility.GetKeyTangentMode(key, 0);
                TangentMode mode2          = CurveUtility.GetKeyTangentMode(key, 1);
                bool        keyBroken      = CurveUtility.GetKeyBroken(key);
                if ((keyTangentMode != TangentMode.Smooth) || (mode2 != TangentMode.Smooth))
                {
                    on = false;
                }
                if ((keyBroken || (keyTangentMode != TangentMode.Editable)) || (mode2 != TangentMode.Editable))
                {
                    flag3 = false;
                }
                if ((keyBroken || (keyTangentMode != TangentMode.Editable)) || (((key.inTangent != 0f) || (mode2 != TangentMode.Editable)) || (key.outTangent != 0f)))
                {
                    flag4 = false;
                }
                if (!keyBroken)
                {
                    flag5 = false;
                }
                if (!keyBroken || (keyTangentMode != TangentMode.Editable))
                {
                    flag6 = false;
                }
                if (!keyBroken || (keyTangentMode != TangentMode.Linear))
                {
                    flag7 = false;
                }
                if (!keyBroken || (keyTangentMode != TangentMode.Stepped))
                {
                    flag8 = false;
                }
                if (!keyBroken || (mode2 != TangentMode.Editable))
                {
                    flag9 = false;
                }
                if (!keyBroken || (mode2 != TangentMode.Linear))
                {
                    flag10 = false;
                }
                if (!keyBroken || (mode2 != TangentMode.Stepped))
                {
                    flag11 = false;
                }
            }
            if (flag)
            {
                menu.AddItem(EditorGUIUtility.TextContent("Auto"), on, new GenericMenu.MenuFunction2(this.SetSmooth), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Free Smooth"), flag3, new GenericMenu.MenuFunction2(this.SetEditable), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Flat"), flag4, new GenericMenu.MenuFunction2(this.SetFlat), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Broken"), flag5, new GenericMenu.MenuFunction2(this.SetBroken), keyList);
                menu.AddSeparator(string.Empty);
                menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Free"), flag6, new GenericMenu.MenuFunction2(this.SetLeftEditable), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Linear"), flag7, new GenericMenu.MenuFunction2(this.SetLeftLinear), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Constant"), flag8, new GenericMenu.MenuFunction2(this.SetLeftConstant), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Free"), flag9, new GenericMenu.MenuFunction2(this.SetRightEditable), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Linear"), flag10, new GenericMenu.MenuFunction2(this.SetRightLinear), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Constant"), flag11, new GenericMenu.MenuFunction2(this.SetRightConstant), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Free"), flag9 && flag6, new GenericMenu.MenuFunction2(this.SetBothEditable), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Linear"), flag10 && flag7, new GenericMenu.MenuFunction2(this.SetBothLinear), keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Constant"), flag11 && flag8, new GenericMenu.MenuFunction2(this.SetBothConstant), keyList);
            }
            else
            {
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Auto"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Free Smooth"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Flat"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Broken"));
                menu.AddSeparator(string.Empty);
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Free"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Linear"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Constant"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Free"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Linear"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Constant"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Free"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Linear"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Constant"));
            }
        }
コード例 #14
0
        public void AddTangentMenuItems(GenericMenu menu, List <KeyIdentifier> keyList)
        {
            bool flag = keyList.Count > 0;
            bool on1  = flag;
            bool on2  = flag;
            bool on3  = flag;
            bool on4  = flag;
            bool on5  = flag;
            bool on6  = flag;
            bool on7  = flag;
            bool on8  = flag;
            bool on9  = flag;
            bool on10 = flag;

            using (List <KeyIdentifier> .Enumerator enumerator = keyList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Keyframe    keyframe        = enumerator.Current.keyframe;
                    TangentMode keyTangentMode1 = CurveUtility.GetKeyTangentMode(keyframe, 0);
                    TangentMode keyTangentMode2 = CurveUtility.GetKeyTangentMode(keyframe, 1);
                    bool        keyBroken       = CurveUtility.GetKeyBroken(keyframe);
                    if (keyTangentMode1 != TangentMode.Smooth || keyTangentMode2 != TangentMode.Smooth)
                    {
                        on1 = false;
                    }
                    if (keyBroken || keyTangentMode1 != TangentMode.Editable || keyTangentMode2 != TangentMode.Editable)
                    {
                        on2 = false;
                    }
                    if (keyBroken || keyTangentMode1 != TangentMode.Editable || ((double)keyframe.inTangent != 0.0 || keyTangentMode2 != TangentMode.Editable) || (double)keyframe.outTangent != 0.0)
                    {
                        on3 = false;
                    }
                    if (!keyBroken)
                    {
                        on4 = false;
                    }
                    if (!keyBroken || keyTangentMode1 != TangentMode.Editable)
                    {
                        on5 = false;
                    }
                    if (!keyBroken || keyTangentMode1 != TangentMode.Linear)
                    {
                        on6 = false;
                    }
                    if (!keyBroken || keyTangentMode1 != TangentMode.Stepped)
                    {
                        on7 = false;
                    }
                    if (!keyBroken || keyTangentMode2 != TangentMode.Editable)
                    {
                        on8 = false;
                    }
                    if (!keyBroken || keyTangentMode2 != TangentMode.Linear)
                    {
                        on9 = false;
                    }
                    if (!keyBroken || keyTangentMode2 != TangentMode.Stepped)
                    {
                        on10 = false;
                    }
                }
            }
            if (flag)
            {
                menu.AddItem(EditorGUIUtility.TextContent("Auto"), on1, new GenericMenu.MenuFunction2(this.SetSmooth), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Free Smooth"), on2, new GenericMenu.MenuFunction2(this.SetEditable), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Flat"), on3, new GenericMenu.MenuFunction2(this.SetFlat), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Broken"), on4, new GenericMenu.MenuFunction2(this.SetBroken), (object)keyList);
                menu.AddSeparator(string.Empty);
                menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Free"), on5, new GenericMenu.MenuFunction2(this.SetLeftEditable), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Linear"), on6, new GenericMenu.MenuFunction2(this.SetLeftLinear), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Constant"), on7, new GenericMenu.MenuFunction2(this.SetLeftConstant), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Free"), on8, new GenericMenu.MenuFunction2(this.SetRightEditable), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Linear"), on9, new GenericMenu.MenuFunction2(this.SetRightLinear), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Constant"), on10, new GenericMenu.MenuFunction2(this.SetRightConstant), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Free"), on8 && on5, new GenericMenu.MenuFunction2(this.SetBothEditable), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Linear"), on9 && on6, new GenericMenu.MenuFunction2(this.SetBothLinear), (object)keyList);
                menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Constant"), on10 && on7, new GenericMenu.MenuFunction2(this.SetBothConstant), (object)keyList);
            }
            else
            {
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Auto"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Free Smooth"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Flat"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Broken"));
                menu.AddSeparator(string.Empty);
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Free"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Linear"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Constant"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Free"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Linear"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Constant"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Free"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Linear"));
                menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Constant"));
            }
        }