Exemple #1
0
    private void collectClipCurves(AnimationClip clip, ref Dictionary <string, TargetCurveSet> targetCurves)
    {
        foreach (var binding in AnimationUtility.GetCurveBindings(clip))
        {
            AnimationCurve curve = AnimationUtility.GetEditorCurve(clip, binding);

            if (!targetCurves.ContainsKey(binding.path))
            {
                TargetCurveSet curveSet = new TargetCurveSet();
                curveSet.Init();
                targetCurves.Add(binding.path, curveSet);
            }

            TargetCurveSet current = targetCurves[binding.path];
            if (binding.propertyName.Contains("m_LocalPosition"))
            {
                if (binding.propertyName.Contains(".x"))
                {
                    current.translationCurves[0] = curve;
                }
                else if (binding.propertyName.Contains(".y"))
                {
                    current.translationCurves[1] = curve;
                }
                else if (binding.propertyName.Contains(".z"))
                {
                    current.translationCurves[2] = curve;
                }
            }
            else if (binding.propertyName.Contains("m_LocalScale"))
            {
                if (binding.propertyName.Contains(".x"))
                {
                    current.scaleCurves[0] = curve;
                }
                else if (binding.propertyName.Contains(".y"))
                {
                    current.scaleCurves[1] = curve;
                }
                else if (binding.propertyName.Contains(".z"))
                {
                    current.scaleCurves[2] = curve;
                }
            }
            else if (binding.propertyName.ToLower().Contains("localrotation"))
            {
                current.rotationType = ROTATION_TYPE.QUATERNION;
                if (binding.propertyName.Contains(".x"))
                {
                    current.rotationCurves[0] = curve;
                }
                else if (binding.propertyName.Contains(".y"))
                {
                    current.rotationCurves[1] = curve;
                }
                else if (binding.propertyName.Contains(".z"))
                {
                    current.rotationCurves[2] = curve;
                }
                else if (binding.propertyName.Contains(".w"))
                {
                    current.rotationCurves[3] = curve;
                }
            }
            // Takes into account 'localEuler', 'localEulerAnglesBaked' and 'localEulerAnglesRaw'
            else if (binding.propertyName.ToLower().Contains("localeuler"))
            {
                current.rotationType = ROTATION_TYPE.EULER;
                if (binding.propertyName.Contains(".x"))
                {
                    current.rotationCurves[0] = curve;
                }
                else if (binding.propertyName.Contains(".y"))
                {
                    current.rotationCurves[1] = curve;
                }
                else if (binding.propertyName.Contains(".z"))
                {
                    current.rotationCurves[2] = curve;
                }
            }
            targetCurves[binding.path] = current;
        }
    }
Exemple #2
0
    private void collectClipCurves(AnimationClip clip, ref Dictionary <string, TargetCurveSet> targetCurves)
    {
        foreach (var binding in AnimationUtility.GetCurveBindings(clip))
        {
            AnimationCurve curve = AnimationUtility.GetEditorCurve(clip, binding);

            if (!targetCurves.ContainsKey(binding.path))
            {
                TargetCurveSet curveSet = new TargetCurveSet();
                curveSet.Init();
                targetCurves.Add(binding.path, curveSet);
            }

            TargetCurveSet current = targetCurves[binding.path];
            if (binding.propertyName.Contains("m_LocalPosition"))
            {
                if (binding.propertyName.Contains(".x"))
                {
                    current.translationCurves[0] = curve;
                }
                else if (binding.propertyName.Contains(".y"))
                {
                    current.translationCurves[1] = curve;
                }
                else if (binding.propertyName.Contains(".z"))
                {
                    current.translationCurves[2] = curve;
                }
            }
            else if (binding.propertyName.Contains("m_LocalScale"))
            {
                if (binding.propertyName.Contains(".x"))
                {
                    current.scaleCurves[0] = curve;
                }
                else if (binding.propertyName.Contains(".y"))
                {
                    current.scaleCurves[1] = curve;
                }
                else if (binding.propertyName.Contains(".z"))
                {
                    current.scaleCurves[2] = curve;
                }
            }
            else if (binding.propertyName.Contains("m_LocalRotation"))
            {
                if (binding.propertyName.Contains(".x"))
                {
                    current.rotationCurves[0] = curve;
                }
                else if (binding.propertyName.Contains(".y"))
                {
                    current.rotationCurves[1] = curve;
                }
                else if (binding.propertyName.Contains(".z"))
                {
                    current.rotationCurves[2] = curve;
                }
                else if (binding.propertyName.Contains(".w"))
                {
                    current.rotationCurves[3] = curve;
                }
            }
        }
    }