mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-24 21:38:59 +08:00
chore: use SerializedObject to clone animations
This commit is contained in:
parent
823b1215e7
commit
a837008f3a
@ -314,27 +314,17 @@ namespace nadena.dev.ndmf.animation
|
|||||||
AssetDatabase.AddObjectToAsset(newClip, _combined);
|
AssetDatabase.AddObjectToAsset(newClip, _combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var binding in AnimationUtility.GetCurveBindings(clip))
|
SerializedObject srcSO = new SerializedObject(clip);
|
||||||
|
SerializedObject destSO = new SerializedObject(newClip);
|
||||||
|
|
||||||
|
SerializedProperty iter = srcSO.GetIterator();
|
||||||
|
|
||||||
|
while (iter.Next(false))
|
||||||
{
|
{
|
||||||
var newBinding = binding;
|
destSO.CopyFromSerializedProperty(iter);
|
||||||
newBinding.path = MapPath(binding, basePath);
|
|
||||||
newClip.SetCurve(newBinding.path, newBinding.type, newBinding.propertyName,
|
|
||||||
AnimationUtility.GetEditorCurve(clip, binding));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var objBinding in AnimationUtility.GetObjectReferenceCurveBindings(clip))
|
destSO.ApplyModifiedPropertiesWithoutUndo();
|
||||||
{
|
|
||||||
var newBinding = objBinding;
|
|
||||||
newBinding.path = MapPath(objBinding, basePath);
|
|
||||||
AnimationUtility.SetObjectReferenceCurve(newClip, newBinding,
|
|
||||||
AnimationUtility.GetObjectReferenceCurve(clip, objBinding));
|
|
||||||
}
|
|
||||||
|
|
||||||
newClip.wrapMode = clip.wrapMode;
|
|
||||||
newClip.legacy = clip.legacy;
|
|
||||||
newClip.frameRate = clip.frameRate;
|
|
||||||
newClip.localBounds = clip.localBounds;
|
|
||||||
AnimationUtility.SetAnimationClipSettings(newClip, AnimationUtility.GetAnimationClipSettings(clip));
|
|
||||||
|
|
||||||
return newClip;
|
return newClip;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user