コード例 #1
0
        public void AddRows(int[] rows, RuntimeAnimationProperty[] properties, bool isNew = true)
        {
            //if(isNew)
            //{
            //    OnClipBeginModify();
            //}

            int parentIndex = 0;

            for (int i = 0; i < properties.Length; ++i)
            {
                RuntimeAnimationProperty property = properties[i];

                if (property.ComponentTypeName == RuntimeAnimationProperty.k_SpecialEmptySpace)
                {
                    Dopesheet.AddRow(true, isNew, -1, 0, null);
                }
                else
                {
                    if (property.Parent == null)
                    {
                        if (property.Curve != null)
                        {
                            Dopesheet.AddRow(true, isNew, 0, property.FloatValue, property.Curve);
                        }
                        else
                        {
                            parentIndex = rows[i];
                            Dopesheet.AddRow(true, isNew, 0, 0, null);
                        }
                    }
                    else
                    {
                        Dopesheet.AddRow(false, isNew, parentIndex, property.FloatValue, property.Curve);
                    }
                }
            }

            if (isNew)
            {
                OnClipModified();
            }
            else
            {
                float clipLength = Clip.Clip.length;
                Dopesheet.BeginSetKeyframeValues(false);
                for (int i = 0; i < properties.Length; ++i)
                {
                    RuntimeAnimationProperty property = properties[i];
                    if (property.ComponentTypeName == RuntimeAnimationProperty.k_SpecialEmptySpace)
                    {
                        continue;
                    }

                    AnimationCurve curve = property.Curve;
                    if (curve != null)
                    {
                        Keyframe[] keys = curve.keys;
                        for (int k = 0; k < keys.Length; ++k)
                        {
                            Keyframe kf = keys[k];

                            int sample = Mathf.RoundToInt(kf.time * Dopesheet.SamplesCount / clipLength);
                            Dopesheet.SetKeyframeValue(kf.value, rows[i], sample);
                        }
                    }
                }
                Dopesheet.EndSetKeyframeValues(false);
            }
        }
コード例 #2
0
 public void SetKeyframeValue(int row, RuntimeAnimationProperty property)
 {
     Dopesheet.SetKeyframeValue(Convert.ToSingle(property.Value), row);
 }