Example #1
0
 public void BuildInternalCurveFromAnimationCurve()
 {
     Keyframe[] keys = this.animationCurve.keys;
     for (int i = 0; i < keys.Length; i++)
     {
         Keyframe           keyframe           = keys[i];
         USInternalKeyframe uSInternalKeyframe = null;
         foreach (USInternalKeyframe current in this.internalKeyframes)
         {
             if (Mathf.Approximately(keyframe.time, current.Time))
             {
                 uSInternalKeyframe = current;
                 break;
             }
         }
         if (uSInternalKeyframe)
         {
             uSInternalKeyframe.ConvertFrom(keyframe);
         }
         else
         {
             USInternalKeyframe uSInternalKeyframe2 = ScriptableObject.CreateInstance <USInternalKeyframe>();
             uSInternalKeyframe2.ConvertFrom(keyframe);
             uSInternalKeyframe2.curve = this;
             this.internalKeyframes.Add(uSInternalKeyframe2);
             this.internalKeyframes.Sort(new Comparison <USInternalKeyframe>(USInternalCurve.KeyframeComparer));
         }
     }
 }
Example #2
0
        public void BuildInternalCurveFromAnimationCurve()
        {
            foreach (var keyframe in animationCurve.keys)
            {
                // Check we don't already have a key that is roughly equivilant to this key.
                USInternalKeyframe existingKeyframe = null;
                foreach (var internalKeyframe in internalKeyframes)
                {
                    if (Mathf.Approximately(keyframe.time, internalKeyframe.Time))
                    {
                        existingKeyframe = internalKeyframe;
                        break;
                    }
                }

                if (existingKeyframe)
                {
                    existingKeyframe.ConvertFrom(keyframe);
                    continue;
                }

                var internalkeyframe = CreateInstance <USInternalKeyframe>();
                internalkeyframe.ConvertFrom(keyframe);
                internalkeyframe.curve = this;
                internalKeyframes.Add(internalkeyframe);

                internalKeyframes.Sort(KeyframeComparer);
            }
        }