Selaa lähdekoodia

Merge branch '4.1' into 4.2-beta

Harald Csaszar 2 vuotta sitten
vanhempi
commit
31dc558d66

+ 101 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Materials/SkeletonGraphicFill.mat

@@ -0,0 +1,101 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!21 &2100000
+Material:
+  serializedVersion: 6
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_Name: SkeletonGraphicFill
+  m_Shader: {fileID: 4800000, guid: c02377d9afbb50e49ab27049e59fb5f8, type: 3}
+  m_ShaderKeywords: _USE8NEIGHBOURHOOD_ON
+  m_LightmapFlags: 5
+  m_EnableInstancingVariants: 0
+  m_DoubleSidedGI: 0
+  m_CustomRenderQueue: -1
+  stringTagMap: {}
+  disabledShaderPasses: []
+  m_SavedProperties:
+    serializedVersion: 3
+    m_TexEnvs:
+    - _AlphaTex:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _BumpMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _DetailAlbedoMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _DetailMask:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _DetailNormalMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _EmissionMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _MainTex:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _MetallicGlossMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _OcclusionMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _ParallaxMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    m_Floats:
+    - PixelSnap: 0
+    - _BumpScale: 1
+    - _CanvasGroupCompatible: 0
+    - _ColorMask: 15
+    - _Cutoff: 0.5
+    - _DetailNormalMapScale: 1
+    - _DstBlend: 0
+    - _EnableExternalAlpha: 0
+    - _FillPhase: 1
+    - _Glossiness: 0.5
+    - _Metallic: 0
+    - _Mode: 0
+    - _OcclusionStrength: 1
+    - _OutlineMipLevel: 0
+    - _OutlineOpaqueAlpha: 1
+    - _OutlineReferenceTexWidth: 1024
+    - _OutlineSmoothness: 1
+    - _OutlineWidth: 3
+    - _Parallax: 0.02
+    - _SrcBlend: 1
+    - _Stencil: 0
+    - _StencilComp: 8
+    - _StencilOp: 0
+    - _StencilReadMask: 255
+    - _StencilWriteMask: 255
+    - _StraightAlphaInput: 0
+    - _ThresholdEnd: 0.25
+    - _UVSec: 0
+    - _Use8Neighbourhood: 1
+    - _UseUIAlphaClip: 0
+    - _ZWrite: 1
+    m_Colors:
+    - _Color: {r: 1, g: 1, b: 1, a: 1}
+    - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
+    - _FillColor: {r: 1, g: 1, b: 1, a: 1}
+    - _Flip: {r: 1, g: 1, b: 1, a: 1}
+    - _OutlineColor: {r: 1, g: 1, b: 0, a: 1}
+    - _RendererColor: {r: 1, g: 1, b: 1, a: 1}
+  m_BuildTextureStacks: []

+ 8 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Materials/SkeletonGraphicFill.mat.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c4cd84769cae11444b3d759bea3d1644
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 2100000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 26 - 5
spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs

@@ -505,14 +505,14 @@ namespace Spine.Unity.AttachmentTools {
 			newSkin.Constraints.AddRange(o.Constraints);
 
 			inoutAttachments.Clear();
-			foreach (var entry in o.Attachments) {
+			foreach (var entry in skinAttachments) {
 				inoutAttachments.Add(entry.Attachment);
 			}
 			GetRepackedAttachments(inoutAttachments, inoutAttachments, materialPropertySource, out outputMaterial, out outputTexture,
 				maxAtlasSize, padding, textureFormat, mipmaps, newName, clearCache, useOriginalNonrenderables,
 				additionalTexturePropertyIDsToCopy, additionalOutputTextures, additionalTextureFormats, additionalTextureIsLinear);
 			int i = 0;
-			foreach (var originalSkinEntry in o.Attachments) {
+			foreach (var originalSkinEntry in skinAttachments) {
 				var newAttachment = inoutAttachments[i++];
 				newSkin.SetAttachment(originalSkinEntry.SlotIndex, originalSkinEntry.Name, newAttachment);
 			}
@@ -680,7 +680,13 @@ 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) {
-			return new Rect(region.x, region.y, region.packedWidth, region.packedHeight);
+			float width = region.packedWidth;
+			float height = region.packedHeight;
+			if (includeRotate && region.degrees == 270) {
+				width = region.packedHeight;
+				height = region.packedWidth;
+			}
+			return new Rect(region.x, region.y, width, height);
 		}
 
 		/// <summary>
@@ -706,13 +712,20 @@ namespace Spine.Unity.AttachmentTools {
 		/// <summary>
 		/// Creates a new Spine AtlasRegion according to a Unity UV Rect (x-right, y-up, uv-normalized).</summary>
 		static AtlasRegion UVRectToAtlasRegion (Rect uvRect, AtlasRegion referenceRegion, AtlasPage page) {
-			var tr = UVRectToTextureRect(uvRect, page.width, page.height);
-			var rr = tr.SpineUnityFlipRect(page.height);
+			Rect tr = UVRectToTextureRect(uvRect, page.width, page.height);
+			Rect rr = tr.SpineUnityFlipRect(page.height);
 
 			int x = (int)rr.x;
 			int y = (int)rr.y;
 			int w = (int)rr.width;
 			int h = (int)rr.height;
+
+			if (referenceRegion.degrees == 270) {
+				int tempW = w;
+				w = h;
+				h = tempW;
+			}
+
 			// Note: originalW and originalH need to be scaled according to the
 			// repacked width and height, repacking can mess with aspect ratio, etc.
 			int originalW = Mathf.RoundToInt((float)w * ((float)referenceRegion.originalWidth / (float)referenceRegion.width));
@@ -726,6 +739,14 @@ namespace Spine.Unity.AttachmentTools {
 			float v = uvRect.yMax;
 			float v2 = uvRect.yMin;
 
+			if (referenceRegion.degrees == 270) {
+				// at a 270 degree region, u2/v2 deltas are swapped, and delta-v is negative.
+				float du = u2 - u;
+				float dv = v - v2;
+				u2 = u + dv;
+				v2 = v - du;
+			}
+
 			return new AtlasRegion {
 				page = page,
 				name = referenceRegion.name,