コード例 #1
0
        public static bool AddAnimatedParameterValueAt(this ICurvesOwner curvesOwner, string parameterName, float value, float time)
        {
            if (!curvesOwner.IsParameterAnimatable(parameterName))
            {
                return(false);
            }

            if (curvesOwner.curves == null)
            {
                curvesOwner.CreateCurves(curvesOwner.GetUniqueRecordedClipName());
            }

            var binding = curvesOwner.GetCurveBinding(parameterName);
            var curve   = AnimationUtility.GetEditorCurve(curvesOwner.curves, binding) ?? new AnimationCurve();

            var serializedObject = AnimatedParameterUtility.GetSerializedPlayableAsset(curvesOwner.asset);
            var property         = serializedObject.FindProperty(parameterName);

            bool isStepped = property.propertyType == SerializedPropertyType.Boolean ||
                             property.propertyType == SerializedPropertyType.Integer ||
                             property.propertyType == SerializedPropertyType.Enum;

            TimelineUndo.PushUndo(curvesOwner.curves, "Set Key");
            CurveEditUtility.AddKeyFrameToCurve(curve, time, curvesOwner.curves.frameRate, value, isStepped);
            AnimationUtility.SetEditorCurve(curvesOwner.curves, binding, curve);

            return(true);
        }
コード例 #2
0
        static bool InternalAddParameter([NotNull] ICurvesOwner curvesOwner, string parameterName, ref EditorCurveBinding binding, out SerializedProperty property)
        {
            property = null;

            if (curvesOwner.IsParameterAnimated(parameterName))
            {
                return(false);
            }

            var serializedObject = AnimatedParameterUtility.GetSerializedPlayableAsset(curvesOwner.asset);

            if (serializedObject == null)
            {
                return(false);
            }

            property = serializedObject.FindProperty(parameterName);
            if (property == null || !AnimatedParameterUtility.IsTypeAnimatable(property.propertyType))
            {
                return(false);
            }

            if (curvesOwner.curves == null)
            {
                curvesOwner.CreateCurves(curvesOwner.GetUniqueRecordedClipName());
            }

            binding = curvesOwner.GetCurveBinding(parameterName);
            return(true);
        }