Skip to content

Commit

Permalink
fix: revert prefab modifications when recording humanoid animation fr…
Browse files Browse the repository at this point in the history
…om prefab assets to work around AnimationMode limitations
  • Loading branch information
hybridherbst committed Feb 14, 2023
1 parent 88fdaf0 commit 6f377c4
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ internal void CollectClipCurvesForHumanoid(GameObject root, AnimationClip clip,
#endif
AnimationMode.BeginSampling();

// if this is a Prefab, we need to collect property modifications here to work around
// limitations of AnimationMode - otherwise prefab modifications will persist...
var isPrefabAsset = PrefabUtility.IsPartOfPrefabAsset(root);
var prefabModifications = isPrefabAsset ? PrefabUtility.GetPropertyModifications(root) : default;

// add the root since we need to shift it around -
// it will be reset when exiting AnimationMode again and will not be dirty.
AnimationMode_AddTransformTRS(root);
Expand Down Expand Up @@ -87,6 +92,11 @@ internal void CollectClipCurvesForHumanoid(GameObject root, AnimationClip clip,
AnimationMode.StopAnimationMode();
#endif

// reset prefab modifications if this was a prefab asset
if (isPrefabAsset) {
PrefabUtility.SetPropertyModifications(root, prefabModifications);
}

recorder.EndRecording(out var data);
if (data == null || !data.Any()) return;

Expand Down

0 comments on commit 6f377c4

Please sign in to comment.