diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3a9b42903..621e1dddd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -401,6 +401,7 @@
* Added an example component `RootMotionDeltaCompensation` located in `Spine Examples/Scripts/Sample Components` which can be used for applying simple delta compensation. You can enable and disable the component to toggle delta compensation of the currently playing animation on and off.
* Root motion delta compensation now allows to only adjust X or Y components instead of both. Adds two parameters to `SkeletonRootMotionBase.AdjustRootMotionToDistance()` which default to adjusting both X and Y as before. The `RootMotionDeltaCompensation` example component exposes these parameters as public attributes.
* Root motion delta compensation now allows to also add translation root motion to e.g. adjust a horizontal jump upwards or downwards over time. This is necessary because a Y root motion of zero cannot be scaled to become non-zero.
+ * `Attachment.GetRemappedClone(Sprite)` method now provides an additional optional parameter `useOriginalRegionScale`. When set to `true`, the replaced attachment's scale is used instead of the Sprite's `Pixel per Unity` setting, allowing for more consistent scaling. *Note:* When remapping Sprites, be sure to set the Sprite's `Mesh Type` to `Full Rect` and not `Tight`, otherwise the scale will be wrong.
* **Changes of default values**
* `SkeletonMecanim`'s `Layer Mix Mode` now defaults to `MixMode.MixNext` instead of `MixMode.MixAlways`.
diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentCloneExtensions.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentCloneExtensions.cs
index 8657ea69d..7ac8c5f12 100644
--- a/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentCloneExtensions.cs
+++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AttachmentCloneExtensions.cs
@@ -48,16 +48,25 @@ namespace Spine.Unity.AttachmentTools {
/// If true and the original Attachment is a MeshAttachment, then
/// a non-central sprite pivot will shift uv coords in the opposite direction. Vertices will not be offset in
/// any case when the original Attachment is a MeshAttachment.
+ /// If true and the original Attachment is a RegionAttachment, then
+ /// the original region's scale value is used instead of the Sprite's pixels per unit property. Since uniform scale is used,
+ /// x scale of the original attachment (width scale) is used, scale in y direction (height scale) is ignored.
public static Attachment GetRemappedClone (this Attachment o, Sprite sprite, Material sourceMaterial,
bool premultiplyAlpha = true, bool cloneMeshAsLinked = true, bool useOriginalRegionSize = false,
- bool pivotShiftsMeshUVCoords = true) {
+ bool pivotShiftsMeshUVCoords = true, bool useOriginalRegionScale = false) {
var atlasRegion = premultiplyAlpha ? sprite.ToAtlasRegionPMAClone(sourceMaterial) : sprite.ToAtlasRegion(new Material(sourceMaterial) { mainTexture = sprite.texture } );
if (!pivotShiftsMeshUVCoords && o is MeshAttachment) {
// prevent non-central sprite pivot setting offsetX/Y and shifting uv coords out of mesh bounds
atlasRegion.offsetX = 0;
atlasRegion.offsetY = 0;
}
- return o.GetRemappedClone(atlasRegion, cloneMeshAsLinked, useOriginalRegionSize, 1f/sprite.pixelsPerUnit);
+ float scale = 1f / sprite.pixelsPerUnit;
+ if (useOriginalRegionScale) {
+ var regionAttachment = o as RegionAttachment;
+ if (regionAttachment != null)
+ scale = regionAttachment.width / regionAttachment.regionOriginalWidth;
+ }
+ return o.GetRemappedClone(atlasRegion, cloneMeshAsLinked, useOriginalRegionSize, scale);
}
///