private void ResampleAnimation(ResampleFlags flags) { if (state.disabled) { return; } if (previewing == false) { return; } if (canPreview == false) { return; } s_ResampleAnimationMarker.Begin(); if (state.activeAnimationClip != null) { var animationPlayer = state.activeAnimationPlayer; bool usePlayableGraph = animationPlayer is Animator; if (usePlayableGraph) { var isValidGraph = m_Graph.IsValid(); if (isValidGraph) { var playableOutput = (AnimationPlayableOutput)m_Graph.GetOutput(0); isValidGraph = playableOutput.GetTarget() == (Animator)animationPlayer; } if (HasFlag(flags, ResampleFlags.RebuildGraph) || !isValidGraph) { RebuildGraph((Animator)animationPlayer); } } AnimationMode.BeginSampling(); if (HasFlag(flags, ResampleFlags.FlushUndos)) { Undo.FlushUndoRecordObjects(); } if (usePlayableGraph) { if (m_UsesPostProcessComponents) { IAnimationWindowPreview[] previewComponents = FetchPostProcessComponents(); if (previewComponents != null) { foreach (var component in previewComponents) { component.UpdatePreviewGraph(m_Graph); } } } if (!m_CandidateClip.empty) { AnimationMode.AddCandidates(state.activeRootGameObject, m_CandidateClip); } m_ClipPlayable.SetSampleRate(playing ? -1 : state.activeAnimationClip.frameRate); AnimationMode.SamplePlayableGraph(m_Graph, 0, time.time); // This will cover euler/quaternion matching in basic playable graphs only (animation clip + candidate clip). AnimationUtility.SampleEulerHint(state.activeRootGameObject, state.activeAnimationClip, time.time, WrapMode.Clamp); if (!m_CandidateClip.empty) { AnimationUtility.SampleEulerHint(state.activeRootGameObject, m_CandidateClip, time.time, WrapMode.Clamp); } } else { AnimationMode.SampleAnimationClip(state.activeRootGameObject, state.activeAnimationClip, time.time); if (!m_CandidateClip.empty) { AnimationMode.SampleCandidateClip(state.activeRootGameObject, m_CandidateClip, 0f); } } AnimationMode.EndSampling(); if (HasFlag(flags, ResampleFlags.RefreshViews)) { SceneView.RepaintAll(); InspectorWindow.RepaintAllInspectors(); // Particle editor needs to be manually repainted to refresh the animated properties var particleSystemWindow = ParticleSystemWindow.GetInstance(); if (particleSystemWindow) { particleSystemWindow.Repaint(); } } } s_ResampleAnimationMarker.End(); }