mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-08 11:46:53 +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.SetPixels(pixelBuffer);
|
||||||
destination.Apply();
|
destination.Apply();
|
||||||
} else {
|
} 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>
|
/// <summary>
|
||||||
/// Returns a Rect of the AtlasRegion according to Spine texture coordinates. (x-right, y-down)</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) {
|
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);
|
return new Rect(region.x, region.y, region.height, region.width);
|
||||||
else
|
else
|
||||||
return new Rect(region.x, region.y, region.width, region.height);
|
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 x = (int)rr.x, y = (int)rr.y;
|
||||||
int w, h;
|
int w, h;
|
||||||
if (referenceRegion.rotate) {
|
if (referenceRegion.degrees == 90 || referenceRegion.degrees == 270) {
|
||||||
w = (int)rr.height;
|
w = (int)rr.height;
|
||||||
h = (int)rr.width;
|
h = (int)rr.width;
|
||||||
} else {
|
} else {
|
||||||
@ -690,14 +690,24 @@ namespace Spine.Unity.AttachmentTools {
|
|||||||
int offsetX = Mathf.RoundToInt((float)referenceRegion.offsetX * ((float)w / (float)referenceRegion.width));
|
int offsetX = Mathf.RoundToInt((float)referenceRegion.offsetX * ((float)w / (float)referenceRegion.width));
|
||||||
int offsetY = Mathf.RoundToInt((float)referenceRegion.offsetY * ((float)h / (float)referenceRegion.height));
|
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 {
|
return new AtlasRegion {
|
||||||
page = page,
|
page = page,
|
||||||
name = referenceRegion.name,
|
name = referenceRegion.name,
|
||||||
|
|
||||||
u = uvRect.xMin,
|
u = u,
|
||||||
u2 = uvRect.xMax,
|
u2 = u2,
|
||||||
v = uvRect.yMax,
|
v = v,
|
||||||
v2 = uvRect.yMin,
|
v2 = v2,
|
||||||
|
|
||||||
index = -1,
|
index = -1,
|
||||||
|
|
||||||
@ -710,7 +720,8 @@ namespace Spine.Unity.AttachmentTools {
|
|||||||
x = x,
|
x = x,
|
||||||
y = y,
|
y = y,
|
||||||
|
|
||||||
rotate = referenceRegion.rotate
|
rotate = referenceRegion.rotate,
|
||||||
|
degrees = referenceRegion.degrees
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user