|
@@ -371,9 +371,11 @@ namespace Spine.Unity.Modules.AttachmentTools {
|
|
public static Texture2D ToTexture (this AtlasRegion ar, bool applyImmediately = true, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) {
|
|
public static Texture2D ToTexture (this AtlasRegion ar, bool applyImmediately = true, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) {
|
|
Texture2D sourceTexture = ar.GetMainTexture();
|
|
Texture2D sourceTexture = ar.GetMainTexture();
|
|
Rect r = ar.GetUnityRect(sourceTexture.height);
|
|
Rect r = ar.GetUnityRect(sourceTexture.height);
|
|
- Texture2D output = new Texture2D((int)r.width, (int)r.height, textureFormat, mipmaps);
|
|
|
|
|
|
+ int width = (int)r.width;
|
|
|
|
+ int height = (int)r.height;
|
|
|
|
+ Texture2D output = new Texture2D(width, height, textureFormat, mipmaps);
|
|
output.name = ar.name;
|
|
output.name = ar.name;
|
|
- Color[] pixelBuffer = sourceTexture.GetPixels((int)r.x, (int)r.y, (int)r.width, (int)r.height);
|
|
|
|
|
|
+ Color[] pixelBuffer = sourceTexture.GetPixels((int)r.x, (int)r.y, width, height);
|
|
output.SetPixels(pixelBuffer);
|
|
output.SetPixels(pixelBuffer);
|
|
|
|
|
|
if (applyImmediately)
|
|
if (applyImmediately)
|
|
@@ -453,7 +455,17 @@ namespace Spine.Unity.Modules.AttachmentTools {
|
|
static AtlasRegion UVRectToAtlasRegion (Rect uvRect, string name, AtlasPage page, float offsetX, float offsetY, bool rotate) {
|
|
static AtlasRegion UVRectToAtlasRegion (Rect uvRect, string name, AtlasPage page, float offsetX, float offsetY, bool rotate) {
|
|
var tr = UVRectToTextureRect(uvRect, page.width, page.height);
|
|
var tr = UVRectToTextureRect(uvRect, page.width, page.height);
|
|
var rr = tr.SpineUnityFlipRect(page.height);
|
|
var rr = tr.SpineUnityFlipRect(page.height);
|
|
- int w = (int)rr.width, h = (int)rr.height, x = (int)rr.x, y = (int)rr.y;
|
|
|
|
|
|
+
|
|
|
|
+ int x = (int)rr.x, y = (int)rr.y;
|
|
|
|
+ int w, h;
|
|
|
|
+ if (rotate) {
|
|
|
|
+ w = (int)rr.height;
|
|
|
|
+ h = (int)rr.width;
|
|
|
|
+ } else {
|
|
|
|
+ w = (int)rr.width;
|
|
|
|
+ h = (int)rr.height;
|
|
|
|
+ }
|
|
|
|
+
|
|
return new AtlasRegion {
|
|
return new AtlasRegion {
|
|
page = page,
|
|
page = page,
|
|
name = name,
|
|
name = name,
|