Currently the adapted/animated fields got modified for real and dirty the game object. This is annoying on prefabs since it cause bolded override even though you just want to preview the changes.
We maybe able to emulate the Timeline package's approach where it also use Animation Playables API but it is revertable. The entry point to that should be AnimationMode. How to collect to-revert property from clips could be like in PropertyCollector.cs of Timeline package.
public void AddFromClips(GameObject obj, IEnumerable<AnimationClip> clips)
{
if (Application.isPlaying)
return;
// Add RootMotion TR property in animation mode snapshot as well if animator bindings didn't do it.
var animator = obj.GetComponent<Animator>();
bool addRoot = (animator != null && !animator.isHuman && !animator.applyRootMotion);
m_CurveBindingSet.Clear();
foreach (var c in clips)
{
addRoot |= c.hasRootCurves | c.hasMotionCurves | c.hasRootMotion;
m_CurveBindingSet.UnionWith(AnimationClipCurveCache.Instance.GetCurveInfo(c).rawBindings);
m_CurveBindingSet.UnionWith(AnimationClipCurveCache.Instance.GetCurveInfo(c).objectBindings);
}
m_CurveBindingSet.UnionWith(m_AnimatorCache.GetAnimatorBindings(obj));
foreach (var binding in m_CurveBindingSet)
{
if (binding.type != typeof(Animator) && !IsEulerHint(binding))
AnimationMode.AddEditorCurveBinding(obj, binding);
}
if (addRoot)
AnimationMode.AddTransformTR(obj, string.Empty);
}
Currently the adapted/animated fields got modified for real and dirty the game object. This is annoying on prefabs since it cause bolded override even though you just want to preview the changes.
We maybe able to emulate the Timeline package's approach where it also use Animation Playables API but it is revertable. The entry point to that should be
AnimationMode
. How to collect to-revert property from clips could be like inPropertyCollector.cs
of Timeline package.