Exemplo n.º 1
0
        private List <AnimationWindowKeyframe> GetKeys(PropertyModification[] modifications)
        {
            var keys = new List <AnimationWindowKeyframe>();

            EditorCurveBinding[] bindings = AnimationWindowUtility.PropertyModificationsToEditorCurveBindings(modifications, state.activeRootGameObject, state.activeAnimationClip);
            if (bindings.Length == 0)
            {
                return(keys);
            }

            for (int i = 0; i < state.allCurves.Count; ++i)
            {
                AnimationWindowCurve curve = state.allCurves[i];
                if (Array.Exists(bindings, binding => curve.binding.Equals(binding)))
                {
                    int keyIndex = curve.GetKeyframeIndex(state.time);
                    if (keyIndex >= 0)
                    {
                        keys.Add(curve.m_Keyframes[keyIndex]);
                    }
                }
            }

            return(keys);
        }
        private List <AnimationWindowKeyframe> GetKeys(PropertyModification[] modifications)
        {
            List <AnimationWindowKeyframe> list = new List <AnimationWindowKeyframe>();

            EditorCurveBinding[]           array = AnimationWindowUtility.PropertyModificationsToEditorCurveBindings(modifications, this.state.activeRootGameObject, this.state.activeAnimationClip);
            List <AnimationWindowKeyframe> result;

            if (array.Length == 0)
            {
                result = list;
            }
            else
            {
                for (int i = 0; i < this.state.allCurves.Count; i++)
                {
                    AnimationWindowCurve curve = this.state.allCurves[i];
                    if (Array.Exists <EditorCurveBinding>(array, (EditorCurveBinding binding) => curve.binding.Equals(binding)))
                    {
                        int keyframeIndex = curve.GetKeyframeIndex(this.state.time);
                        if (keyframeIndex >= 0)
                        {
                            list.Add(curve.m_Keyframes[keyframeIndex]);
                        }
                    }
                }
                result = list;
            }
            return(result);
        }
Exemplo n.º 3
0
        private GenericMenu GenerateMenu(List <AnimationWindowHierarchyNode> interactedNodes)
        {
            List <AnimationWindowCurve> curvesAffectedByNodes1 = this.GetCurvesAffectedByNodes(interactedNodes, false);
            List <AnimationWindowCurve> curvesAffectedByNodes2 = this.GetCurvesAffectedByNodes(interactedNodes, true);
            bool        flag1       = curvesAffectedByNodes1.Count == 1 && AnimationWindowUtility.ForceGrouping(curvesAffectedByNodes1[0].binding);
            GenericMenu genericMenu = new GenericMenu();

            genericMenu.AddItem(new GUIContent(curvesAffectedByNodes1.Count > 1 || flag1 ? "Remove Properties" : "Remove Property"), false, new GenericMenu.MenuFunction(this.RemoveCurvesFromSelectedNodes));
            bool flag2 = true;

            EditorCurveBinding[] curves = new EditorCurveBinding[curvesAffectedByNodes2.Count];
            for (int index = 0; index < curvesAffectedByNodes2.Count; ++index)
            {
                curves[index] = curvesAffectedByNodes2[index].binding;
            }
            RotationCurveInterpolation.Mode interpolationMode = this.GetRotationInterpolationMode(curves);
            if (interpolationMode == RotationCurveInterpolation.Mode.Undefined)
            {
                flag2 = false;
            }
            else
            {
                using (List <AnimationWindowHierarchyNode> .Enumerator enumerator = interactedNodes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        if (!(enumerator.Current is AnimationWindowHierarchyPropertyGroupNode))
                        {
                            flag2 = false;
                        }
                    }
                }
            }
            if (flag2)
            {
                string str = !this.state.activeAnimationClip.legacy ? string.Empty : " (Not fully supported in Legacy)";
                genericMenu.AddItem(new GUIContent("Interpolation/Euler Angles" + str), interpolationMode == RotationCurveInterpolation.Mode.RawEuler, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), (object)RotationCurveInterpolation.Mode.RawEuler);
                genericMenu.AddItem(new GUIContent("Interpolation/Euler Angles (Quaternion Approximation)"), interpolationMode == RotationCurveInterpolation.Mode.Baked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), (object)RotationCurveInterpolation.Mode.Baked);
                genericMenu.AddItem(new GUIContent("Interpolation/Quaternion"), interpolationMode == RotationCurveInterpolation.Mode.NonBaked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), (object)RotationCurveInterpolation.Mode.NonBaked);
            }
            if (AnimationMode.InAnimationMode())
            {
                genericMenu.AddSeparator(string.Empty);
                bool flag3 = true;
                bool flag4 = true;
                bool flag5 = true;
                using (List <AnimationWindowCurve> .Enumerator enumerator = curvesAffectedByNodes1.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AnimationWindowCurve current = enumerator.Current;
                        if (!current.HasKeyframe(this.state.time))
                        {
                            flag3 = false;
                        }
                        else
                        {
                            flag4 = false;
                            if (!current.isPPtrCurve)
                            {
                                flag5 = false;
                            }
                        }
                    }
                }
                string text1 = "Add Key";
                if (flag3)
                {
                    genericMenu.AddDisabledItem(new GUIContent(text1));
                }
                else
                {
                    genericMenu.AddItem(new GUIContent(text1), false, new GenericMenu.MenuFunction2(this.AddKeysAtCurrentTime), (object)curvesAffectedByNodes1);
                }
                string text2 = "Delete Key";
                if (flag4)
                {
                    genericMenu.AddDisabledItem(new GUIContent(text2));
                }
                else
                {
                    genericMenu.AddItem(new GUIContent(text2), false, new GenericMenu.MenuFunction2(this.DeleteKeysAtCurrentTime), (object)curvesAffectedByNodes1);
                }
                if (!flag5)
                {
                    genericMenu.AddSeparator(string.Empty);
                    List <KeyIdentifier> keyIdentifierList = new List <KeyIdentifier>();
                    using (List <AnimationWindowCurve> .Enumerator enumerator = curvesAffectedByNodes1.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            AnimationWindowCurve current = enumerator.Current;
                            if (!current.isPPtrCurve)
                            {
                                int keyframeIndex = current.GetKeyframeIndex(this.state.time);
                                if (keyframeIndex != -1)
                                {
                                    CurveRenderer curveRenderer = CurveRendererCache.GetCurveRenderer(this.state.activeAnimationClip, current.binding);
                                    int           curveId       = CurveUtility.GetCurveID(this.state.activeAnimationClip, current.binding);
                                    keyIdentifierList.Add(new KeyIdentifier(curveRenderer, curveId, keyframeIndex));
                                }
                            }
                        }
                    }
                }
            }
            return(genericMenu);
        }