コード例 #1
0
        // updates the just the proxied values. This can be called when the asset changes, so the proxy values are properly updated
        public void UpdateProxyCurves()
        {
            if (!m_IsAnimatable || m_ProxyCurves == null || m_ProxyCurves.empty)
            {
                return;
            }

            AnimatedParameterUtility.UpdateSerializedPlayableAsset(m_OriginalOwner.asset);
            var parameters = m_OriginalOwner.GetAllAnimatableParameters().ToArray();

            using (new RebuildGuard(this))
            {
                if (m_OriginalOwner.hasCurves)
                {
                    var bindingInfo = AnimationClipCurveCache.Instance.GetCurveInfo(m_OriginalOwner.curves);
                    foreach (var param in parameters)
                    {
                        var binding = AnimatedParameterUtility.GetCurveBinding(m_OriginalOwner.asset, param.propertyPath);
                        if (!bindingInfo.bindings.Contains(binding, AnimationPreviewUtilities.EditorCurveBindingComparer.Instance))
                        {
                            SetProxyCurve(param, AnimatedParameterUtility.GetCurveBinding(m_OriginalOwner.asset, param.propertyPath));
                        }
                    }
                }
                else
                {
                    foreach (var param in parameters)
                    {
                        SetProxyCurve(param, AnimatedParameterUtility.GetCurveBinding(m_OriginalOwner.asset, param.propertyPath));
                    }
                }
            }

            AnimationClipCurveCache.Instance.GetCurveInfo(m_ProxyCurves).dirty = true;
        }
コード例 #2
0
        void CreateProxyCurve(SerializedProperty prop, AnimationClip clip, UnityObject owner, string propertyName)
        {
            var binding = AnimatedParameterUtility.GetCurveBinding(owner, propertyName);

            var originalCurve = m_OriginalOwner.hasCurves
                ? AnimationUtility.GetEditorCurve(m_OriginalOwner.curves, binding)
                : null;

            if (originalCurve != null)
            {
                AnimationUtility.SetEditorCurve(clip, binding, originalCurve);
            }
            else
            {
                var curve = new AnimationCurve();

                CurveEditUtility.AddKeyFrameToCurve(
                    curve, 0.0f, clip.frameRate, CurveEditUtility.GetKeyValue(prop),
                    prop.propertyType == SerializedPropertyType.Boolean);

                AnimationUtility.SetEditorCurve(clip, binding, curve);
            }

            m_PropertiesMap[binding] = prop;
        }
コード例 #3
0
        void CreateProxyCurve(SerializedProperty prop, AnimationClip clip, UnityObject owner, string propertyName)
        {
            var binding = AnimatedParameterUtility.GetCurveBinding(owner, propertyName);

            var originalCurve = m_OriginalOwner.hasCurves
                ? AnimationUtility.GetEditorCurve(m_OriginalOwner.curves, binding)
                : null;

            if (originalCurve != null)
            {
                AnimationUtility.SetEditorCurve(clip, binding, originalCurve);
            }
            else
            {
                SetProxyCurve(prop, binding);
            }

            m_PropertiesMap[binding] = prop;
        }
コード例 #4
0
 public static EditorCurveBinding GetCurveBinding(this ICurvesOwner curvesOwner, string parameterName)
 {
     return(AnimatedParameterUtility.GetCurveBinding(curvesOwner.asset, parameterName));
 }