mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[unity] Fixed GetRepackedSkin supporting 270 degree rotation of MeshAttachments (new atlas format, when packed with mode Polygons). Closes #1847.
This commit is contained in:
parent
4a0b30dd2f
commit
38d8a1362a
@ -598,7 +598,7 @@ namespace Spine.Unity.AttachmentTools {
|
||||
destination.SetPixels(pixelBuffer);
|
||||
destination.Apply();
|
||||
} else {
|
||||
Graphics.CopyTexture(source, 0, 0, (int)sourceRect.x, (int)sourceRect.y, (int)sourceRect.width, (int)sourceRect.height, destination, 0, 0, 0, 0);
|
||||
Graphics.CopyTexture(source, 0, 0, (int)sourceRect.x, (int)sourceRect.y, (int)sourceRect.width, (int)sourceRect.height, destination, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -643,7 +643,7 @@ namespace Spine.Unity.AttachmentTools {
|
||||
/// <summary>
|
||||
/// Returns a Rect of the AtlasRegion according to Spine texture coordinates. (x-right, y-down)</summary>
|
||||
static Rect GetSpineAtlasRect (this AtlasRegion region, bool includeRotate = true) {
|
||||
if (includeRotate && region.rotate)
|
||||
if (includeRotate && (region.degrees == 90 || region.degrees == 270))
|
||||
return new Rect(region.x, region.y, region.height, region.width);
|
||||
else
|
||||
return new Rect(region.x, region.y, region.width, region.height);
|
||||
@ -677,7 +677,7 @@ namespace Spine.Unity.AttachmentTools {
|
||||
|
||||
int x = (int)rr.x, y = (int)rr.y;
|
||||
int w, h;
|
||||
if (referenceRegion.rotate) {
|
||||
if (referenceRegion.degrees == 90 || referenceRegion.degrees == 270) {
|
||||
w = (int)rr.height;
|
||||
h = (int)rr.width;
|
||||
} else {
|
||||
@ -690,14 +690,24 @@ namespace Spine.Unity.AttachmentTools {
|
||||
int offsetX = Mathf.RoundToInt((float)referenceRegion.offsetX * ((float)w / (float)referenceRegion.width));
|
||||
int offsetY = Mathf.RoundToInt((float)referenceRegion.offsetY * ((float)h / (float)referenceRegion.height));
|
||||
|
||||
if (referenceRegion.degrees == 270) {
|
||||
w = (int)rr.width;
|
||||
h = (int)rr.height;
|
||||
}
|
||||
|
||||
float u = uvRect.xMin;
|
||||
float u2 = uvRect.xMax;
|
||||
float v = uvRect.yMax;
|
||||
float v2 = uvRect.yMin;
|
||||
|
||||
return new AtlasRegion {
|
||||
page = page,
|
||||
name = referenceRegion.name,
|
||||
|
||||
u = uvRect.xMin,
|
||||
u2 = uvRect.xMax,
|
||||
v = uvRect.yMax,
|
||||
v2 = uvRect.yMin,
|
||||
u = u,
|
||||
u2 = u2,
|
||||
v = v,
|
||||
v2 = v2,
|
||||
|
||||
index = -1,
|
||||
|
||||
@ -710,7 +720,8 @@ namespace Spine.Unity.AttachmentTools {
|
||||
x = x,
|
||||
y = y,
|
||||
|
||||
rotate = referenceRegion.rotate
|
||||
rotate = referenceRegion.rotate,
|
||||
degrees = referenceRegion.degrees
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user