Skip to content

Commit

Permalink
Merge pull request #700 from anatawa12/move-only-not-path-changed
Browse files Browse the repository at this point in the history
Move only not path changed
  • Loading branch information
anatawa12 authored Nov 8, 2023
2 parents daf036d + 1515b9c commit 81d012f
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 117 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog].
### Fixed
- eyelids BlendShape Removed error for non-AAO avatars `#696`
- bounds can be changed in apply on play if updateWhenOffscreen is true `#697`
- Animations for most components under MergeBone is not mapped `#700`

### Security

Expand Down
21 changes: 1 addition & 20 deletions Editor/ObjectMapping/AnimationObjectMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public string MapPath(string srcPath, Type type)
{
// if mapped one is exactly same as original, return null
if (newProp.AllCopiedTo.Length == 1
&& gameObjectInfo.NewPath == path
&& newProp.AllCopiedTo[0].InstanceId == instanceId
&& newProp.AllCopiedTo[0].Name == propertyName)
return null;
Expand Down Expand Up @@ -186,25 +187,5 @@ public string MapPath(string srcPath, Type type)
return new[] { (gameObjectInfo.NewPath, type, propertyName) };
}
}

[CanBeNull]
public EditorCurveBinding[] MapBinding(EditorCurveBinding binding)
{
var mappedBindings = MapBinding(binding.path, binding.type, binding.propertyName);
if (mappedBindings == null)
{
return null;
}

var curveBindings = new EditorCurveBinding[mappedBindings.Length];
for (var i = 0; i < mappedBindings.Length; i++)
{
binding.path = mappedBindings[i].path;
binding.type = mappedBindings[i].type;
binding.propertyName = mappedBindings[i].propertyName;
curveBindings[i] = binding; // copy everything else
}
return curveBindings;
}
}
}
12 changes: 8 additions & 4 deletions Editor/ObjectMapping/ObjectMappingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private Object CustomClone(Object o)

foreach (var binding in AnimationUtility.GetCurveBindings(clip))
{
var newBindings = _mapping.MapBinding(binding);
var newBindings = _mapping.MapBinding(binding.path, binding.type, binding.propertyName);
if (newBindings == null)
{
newClip.SetCurve(binding.path, binding.type, binding.propertyName,
Expand All @@ -195,7 +195,7 @@ private Object CustomClone(Object o)

foreach (var binding in AnimationUtility.GetObjectReferenceCurveBindings(clip))
{
var newBindings = _mapping.MapBinding(binding);
var newBindings = _mapping.MapBinding(binding.path, binding.type, binding.propertyName);
if (newBindings == null)
{
AnimationUtility.SetObjectReferenceCurve(newClip, binding,
Expand All @@ -204,10 +204,14 @@ private Object CustomClone(Object o)
else
{
_mapped = true;
foreach (var newBinding in newBindings)
foreach (var tuple in newBindings)
{
var newBinding = binding;
newBinding.path = tuple.path;
newBinding.type = tuple.type;
newBinding.propertyName = tuple.propertyName;
AnimationUtility.SetObjectReferenceCurve(newClip, newBinding,
AnimationUtility.GetObjectReferenceCurve(clip, binding));
AnimationUtility.GetObjectReferenceCurve(clip, newBinding));
}
}
}
Expand Down
Loading

0 comments on commit 81d012f

Please sign in to comment.