示例#1
0
        void OnCurveModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType type)
        {
            InspectorWindow.RepaintAllInspectors();
            if (state == null)
            {
                return;
            }

            if (type == AnimationUtility.CurveModifiedType.CurveModified)
            {
                Playable playable;
                if (m_PlayableLookup.GetPlayableFromAnimClip(clip, out playable))
                {
                    playable.SetAnimatedProperties(clip);
                }

                // updates the duration of the graph without rebuilding
                AnimationUtility.SyncEditorCurves(clip); // deleted keys are not synced when this is sent out, so duration could be incorrect
                state.UpdateRootPlayableDuration(state.editSequence.duration);

                // don't evaluate if this is caused by recording on an animation track, the extra evaluation can cause hiccups
                if (!TimelineRecording.IsRecordingAnimationTrack)
                {
                    state.Evaluate();
                }
            }
            else // curve added/removed, or clip added/removed
            {
                state.rebuildGraph = true;
            }
        }
        // callback when a curve is edited. Force the cache to update next time it's accessed
        void OnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType modification)
        {
            AnimationClipCurveInfo data;

            if (m_ClipCache.TryGetValue(clip, out data))
            {
                data.dirty = true;
            }
        }
        void OnCurveModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType type)
        {
            InspectorWindow.RepaintAllInspectors();
            if (state == null || state.rebuildGraph)
            {
                return;
            }

            //Force refresh of curve when modified by another editor.
            Repaint();

            if (state.previewMode == false)
            {
                return;
            }

            bool hasPlayable = m_PlayableLookup.GetPlayableFromAnimClip(clip, out Playable playable);

            // mark the timeline clip as dirty
            TimelineClip timelineClip = m_PlayableLookup.GetTimelineClipFromCurves(clip);

            if (timelineClip != null)
            {
                timelineClip.MarkDirty();
            }

            if (type == AnimationUtility.CurveModifiedType.CurveModified)
            {
                if (hasPlayable)
                {
                    playable.SetAnimatedProperties(clip);
                }

                // updates the duration of the graph without rebuilding
                AnimationUtility.SyncEditorCurves(clip); // deleted keys are not synced when this is sent out, so duration could be incorrect
                state.UpdateRootPlayableDuration(state.editSequence.duration);

                bool             isRecording    = TimelineRecording.IsRecordingAnimationTrack;
                PlayableDirector masterDirector = TimelineEditor.masterDirector;
                bool             isGraphValid   = masterDirector != null && masterDirector.playableGraph.IsValid();

                // don't evaluate if this is caused by recording on an animation track, the extra evaluation can cause hiccups
                // Prevent graphs to be resurrected  by a changed clip.
                if (!isRecording && isGraphValid)
                {
                    state.Evaluate();
                }
            }
            else if (EditorUtility.IsDirty(clip)) // curve added/removed, or clip added/removed
            {
                state.rebuildGraph |= timelineClip != null || hasPlayable;
            }
        }
示例#4
0
 public void OnCurveModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType type)
 {
     if (instance == null)
     {
         return;
     }
     if (dg_OnCurveModified == null || dg_OnCurveModified.Target != (object)instance)
     {
         var mi_OnCurveModified = instance.GetType().GetMethod("OnCurveModified", BindingFlags.Instance | BindingFlags.NonPublic);
         dg_OnCurveModified = (Action <AnimationClip, EditorCurveBinding, AnimationUtility.CurveModifiedType>)Delegate.CreateDelegate(typeof(Action <AnimationClip, EditorCurveBinding, AnimationUtility.CurveModifiedType>), instance, mi_OnCurveModified);
     }
     dg_OnCurveModified(clip, binding, type);
 }
示例#5
0
 // callback when a curve is edited. Force the cache to update next time it's accessed
 void OnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType modification)
 {
     if (modification == AnimationUtility.CurveModifiedType.CurveDeleted)
     {
         m_ClipCache.Remove(clip);
     }
     else
     {
         AnimationClipCurveInfo data;
         if (m_ClipCache.TryGetValue(clip, out data))
         {
             data.dirty = true;
         }
     }
 }
示例#6
0
        static void OnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType deleted)
        {
            AnimationUtility.onCurveWasModified -= OnCurveWasModified;

            bool flag = Event.current == null ||
                        (Event.current != null && Event.current.type != EventType.ExecuteCommand);

            var rootGameOject = AnimationWindowExtra.rootGameObject;

            if (flag &&
                rootGameOject &&
                deleted == AnimationUtility.CurveModifiedType.CurveModified &&
                binding.type == typeof(Transform) &&
                binding.propertyName.Contains("localEulerAnglesRaw"))
            {
                Transform transform   = AnimationWindowExtra.rootGameObject.transform.Find(binding.path);
                Vector3   eulerAngles = BoneUtils.GetLocalEulerAngles(transform);

                int frame = AnimationWindowExtra.frame;

                AnimationCurve curve = AnimationUtility.GetEditorCurve(clip, binding);

                for (int i = 0; i < curve.length; i++)
                {
                    Keyframe keyframe = curve[i];

                    int keyframeFrame = (int)AnimationWindowExtra.TimeToFrame(keyframe.time);

                    if (frame == keyframeFrame)
                    {
                        if (binding.propertyName.Contains(".x"))
                        {
                            if (keyframe.value != eulerAngles.x)
                            {
                                //Debug.Log(binding.propertyName + "  " + keyframe.value + " -> " + eulerAngles.x.ToString());

                                keyframe.value = eulerAngles.x;
                            }
                        }
                        else if (binding.propertyName.Contains(".y"))
                        {
                            if (keyframe.value != eulerAngles.y)
                            {
                                //Debug.Log(binding.propertyName + "  " + keyframe.value + " -> " + eulerAngles.y.ToString());

                                keyframe.value = eulerAngles.y;
                            }
                        }
                        else if (binding.propertyName.Contains(".z"))
                        {
                            if (keyframe.value != eulerAngles.z)
                            {
                                //Debug.Log(binding.propertyName + "  " + keyframe.value + " -> " + eulerAngles.z.ToString());

                                keyframe.value = eulerAngles.z;
                            }
                        }

                        curve.MoveKey(i, keyframe);

                        CurveUtility.UpdateTangentsFromModeSurrounding(curve, i);

                        break;
                    }
                }

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

            AnimationUtility.onCurveWasModified += OnCurveWasModified;
        }
示例#7
0
    private static void OnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType type)
    {
        if (!enabled && activeAnimationClip != clip)
        {
            return;
        }

        reloadPointsInfo = true;
    }
 void OnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType modification)
 {
     m_ClipCache.Remove(clip);
 }
示例#9
0
        private void OnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType deleted)
        {
            if (instance == null)
            {
                return;
            }
            if (clip != dg_get_m_SourcePreviewMotion(instance))
            {
                return;
            }

            Reset();
        }
示例#10
0
        private void OnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType modification)
        {
            AnimationClipCurveInfo animationClipCurveInfo;

            if (modification == null)
            {
                this.m_ClipCache.Remove(clip);
            }
            else if (this.m_ClipCache.TryGetValue(clip, out animationClipCurveInfo))
            {
                animationClipCurveInfo.dirty = true;
            }
        }
示例#11
0
        static void OnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType curveType)
        {
            // Stop listening for the changed event while we edit the animation
            AnimationUtility.onCurveWasModified -= CharacterAnimationSnap.OnCurveWasModified;

            // Ensure we only alter animatinos under our own path to prevent issues with other ones
            string path = AssetDatabase.GetAssetPath(clip).ToLower();

            if (path.IndexOf("/animatedpixelpack2/characters/animations") >= 0)
            {
                // Find the position curves
                if (curveType == AnimationUtility.CurveModifiedType.CurveModified &&
                    binding.type == typeof(Transform) &&
                    binding.propertyName.Contains("m_LocalPosition"))
                {
                    AnimationCurve curve = AnimationUtility.GetEditorCurve(clip, binding);

                    // Snap each keyframe to the 1/16th unit measurement that equates to one character pixel,
                    // Also make the tangent constant between keyframes.
                    // This is how our unity mecanim animations look like spritesheets rather than being
                    // interpolated at subpixel positions between frames.
                    for (int i = 0; i < curve.keys.Length; i++)
                    {
                        var k = curve.keys[i];
                        k.value        = Mathf.Round(k.value * 16) / 16f;
                        k.weightedMode = WeightedMode.None;
                        curve.MoveKey(i, k);
                        AnimationUtility.SetKeyBroken(curve, i, true);
                        AnimationUtility.SetKeyLeftTangentMode(curve, i, AnimationUtility.TangentMode.Constant);
                        AnimationUtility.SetKeyRightTangentMode(curve, i, AnimationUtility.TangentMode.Constant);
                    }

                    // Update the curve
                    AnimationUtility.SetEditorCurve(clip, binding, curve);
                }
            }

            // Begin listening again
            AnimationUtility.onCurveWasModified += CharacterAnimationSnap.OnCurveWasModified;
        }
 private void CurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType type)
 {
     if (clip != this.m_ActiveAnimationClip)
     {
         return;
     }
     if (type == AnimationUtility.CurveModifiedType.CurveModified)
     {
         bool flag     = false;
         int  hashCode = binding.GetHashCode();
         foreach (AnimationWindowCurve current in this.allCurves)
         {
             int hashCode2 = current.binding.GetHashCode();
             if (hashCode2 == hashCode)
             {
                 this.m_ModifiedCurves.Add(hashCode2);
                 flag = true;
             }
         }
         if (flag)
         {
             this.refresh = AnimationWindowState.RefreshType.CurvesOnly;
         }
         else
         {
             this.m_lastAddedCurveBinding = new EditorCurveBinding?(binding);
             this.refresh = AnimationWindowState.RefreshType.Everything;
         }
     }
     else
     {
         this.refresh = AnimationWindowState.RefreshType.Everything;
     }
 }
示例#13
0
        public static void OnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType deleted)
        {
            Debug.Log("onEvent:" + binding.path + "," + deleted);

            if (deleted == AnimationUtility.CurveModifiedType.CurveModified)
            {
                binding.path = "Cube";
            }
        }
示例#14
0
 private static void Internal_CallOnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType type)
 {
     if (AnimationUtility.onCurveWasModified != null)
     {
         AnimationUtility.onCurveWasModified(clip, binding, type);
     }
 }