private static bool InternalAddParameter(TimelineClip clip, string parameterName, ref EditorCurveBinding binding, out SerializedProperty property)
        {
            property = null;
            bool result;

            if (clip.IsParameterAnimated(parameterName))
            {
                result = false;
            }
            else
            {
                SerializedObject serializedObject = AnimatedParameterExtensions.GetSerializedObject(clip);
                if (serializedObject == null)
                {
                    result = false;
                }
                else
                {
                    property = serializedObject.FindProperty(parameterName);
                    if (property == null || !AnimatedParameterExtensions.IsAnimatable(property.get_propertyType()))
                    {
                        result = false;
                    }
                    else
                    {
                        AnimatedParameterExtensions.CreateCurvesIfRequired(clip, null);
                        binding = clip.GetCurveBinding(parameterName);
                        result  = true;
                    }
                }
            }
            return(result);
        }
        public static bool SetAnimatedParameter(this TimelineClip clip, string parameterName, AnimationCurve curve)
        {
            bool result;

            if (!clip.IsParameterAnimated(parameterName) && !clip.AddAnimatedParameter(parameterName))
            {
                result = false;
            }
            else
            {
                EditorCurveBinding curveBinding = clip.GetCurveBinding(parameterName);
                AnimationUtility.SetEditorCurve(clip.curves, curveBinding, curve);
                result = true;
            }
            return(result);
        }
        public static bool RemoveAnimatedParameter(this TimelineClip clip, string parameterName)
        {
            bool result;

            if (!clip.IsParameterAnimated(parameterName) || clip.curves == null)
            {
                result = false;
            }
            else
            {
                EditorCurveBinding curveBinding = clip.GetCurveBinding(parameterName);
                AnimationUtility.SetEditorCurve(clip.curves, curveBinding, null);
                result = true;
            }
            return(result);
        }
Ejemplo n.º 4
0
        private static void PreparePlayableAsset(ClipInspector.EditorClipSelection selectedItem)
        {
            if (Event.get_current().get_type() == 7)
            {
                if (selectedItem.playableAssetObject != null)
                {
                    TimelineClip clip = selectedItem.clip;
                    if (clip != null && !(clip.curves == null))
                    {
                        TimelineWindow instance = TimelineWindow.instance;
                        if (!(instance == null) && instance.state != null)
                        {
                            if (!instance.state.previewMode)
                            {
                                selectedItem.lastEvalTime = -1.0;
                            }
                            else
                            {
                                double num = instance.state.time;
                                num = clip.ToLocalTime(num);
                                if (selectedItem.lastEvalTime == num)
                                {
                                    int version = AnimationClipCurveCache.Instance.GetCurveInfo(clip.curves).version;
                                    if (version == selectedItem.lastCurveVersion)
                                    {
                                        return;
                                    }
                                    selectedItem.lastCurveVersion = version;
                                }
                                selectedItem.lastEvalTime = num;
                                AnimationClipCurveInfo curveInfo = AnimationClipCurveCache.Instance.GetCurveInfo(clip.curves);
                                if (curveInfo.bindings.Length != 0)
                                {
                                    selectedItem.playableAssetObject.Update();
                                    SerializedProperty iterator = selectedItem.playableAssetObject.GetIterator();
                                    while (iterator.NextVisible(true))
                                    {
                                        if (clip.IsParameterAnimated(iterator.get_propertyPath()))
                                        {
                                            AnimationCurve         animatedParameter = clip.GetAnimatedParameter(iterator.get_propertyPath());
                                            SerializedPropertyType propertyType      = iterator.get_propertyType();
                                            switch (propertyType)
                                            {
                                            case 0:
                                                iterator.set_intValue(Mathf.FloorToInt(animatedParameter.Evaluate((float)num)));
                                                continue;

                                            case 1:
                                                iterator.set_boolValue(animatedParameter.Evaluate((float)num) > 0f);
                                                continue;

                                            case 2:
                                                iterator.set_floatValue(animatedParameter.Evaluate((float)num));
                                                continue;

                                            case 3:
                                            case 5:
                                            case 6:
                                            case 7:
IL_18C:
                                                if (propertyType != 17)
                                                {
                                                    continue;
                                                }
                                                goto IL_222;

                                            case 4:
                                                ClipInspector.SetAnimatedValue(clip, iterator, "r", num);
                                                ClipInspector.SetAnimatedValue(clip, iterator, "g", num);
                                                ClipInspector.SetAnimatedValue(clip, iterator, "b", num);
                                                ClipInspector.SetAnimatedValue(clip, iterator, "a", num);
                                                continue;

                                            case 8:
                                                goto IL_248;

                                            case 9:
                                                goto IL_235;

                                            case 10:
                                                goto IL_222;
                                            }
                                            goto IL_18C;
                                            continue;
IL_248:
                                            ClipInspector.SetAnimatedValue(clip, iterator, "x", num);
                                            ClipInspector.SetAnimatedValue(clip, iterator, "y", num);
                                            continue;
IL_235:
                                            ClipInspector.SetAnimatedValue(clip, iterator, "z", num);
                                            goto IL_248;
IL_222:
                                            ClipInspector.SetAnimatedValue(clip, iterator, "w", num);
                                            goto IL_235;
                                        }
                                    }
                                    selectedItem.playableAssetObject.ApplyModifiedPropertiesWithoutUndo();
                                }
                            }
                        }
                    }
                }
            }
        }