Pārlūkot izejas kodu

Merge remote-tracking branch 'EsotericSoftware/3.6' into 3.6

Stephen Gowen 7 gadi atpakaļ
vecāks
revīzija
945db25c6f

+ 5 - 1
spine-csharp/src/Attachments/Attachment.cs

@@ -34,7 +34,7 @@ namespace Spine {
 	abstract public class Attachment {
 		public string Name { get; private set; }
 
-		public Attachment (String name) {
+		protected Attachment (string name) {
 			if (name == null) throw new ArgumentNullException("name", "name cannot be null");
 			Name = name;
 		}
@@ -43,4 +43,8 @@ namespace Spine {
 			return Name;
 		}
 	}
+
+	public interface IHasRendererObject {
+		object RendererObject { get; }
+	}
 }

+ 2 - 2
spine-csharp/src/Attachments/MeshAttachment.cs

@@ -32,7 +32,7 @@ using System;
 
 namespace Spine {
 	/// <summary>Attachment that displays a texture region using a mesh.</summary>
-	public class MeshAttachment : VertexAttachment {
+	public class MeshAttachment : VertexAttachment, IHasRendererObject {
 		internal float regionOffsetX, regionOffsetY, regionWidth, regionHeight, regionOriginalWidth, regionOriginalHeight;
 		private MeshAttachment parentMesh;
 		internal float[] uvs, regionUVs;
@@ -53,7 +53,7 @@ namespace Spine {
 		public float A { get { return a; } set { a = value; } }
 
 		public string Path { get; set; }
-		public object RendererObject; //public Object RendererObject { get; set; }
+		public object RendererObject { get; set; }
 		public float RegionU { get; set; }
 		public float RegionV { get; set; }
 		public float RegionU2 { get; set; }

+ 2 - 2
spine-csharp/src/Attachments/RegionAttachment.cs

@@ -32,7 +32,7 @@ using System;
 
 namespace Spine {
 	/// <summary>Attachment that displays a texture region.</summary>
-	public class RegionAttachment : Attachment {
+	public class RegionAttachment : Attachment, IHasRendererObject {
 		public const int BLX = 0;
 		public const int BLY = 1;
 		public const int ULX = 2;
@@ -61,7 +61,7 @@ namespace Spine {
 		public float A { get { return a; } set { a = value; } }
 
 		public string Path { get; set; }
-		public object RendererObject; //public object RendererObject { get; set; }
+		public object RendererObject { get; set; }
 		public float RegionOffsetX { get { return regionOffsetX; } set { regionOffsetX = value; } }
 		public float RegionOffsetY { get { return regionOffsetY; } set { regionOffsetY = value; } } // Pixels stripped from the bottom left, unrotated.
 		public float RegionWidth { get { return regionWidth; } set { regionWidth = value; } }

+ 2 - 2
spine-csharp/src/Bone.cs

@@ -246,8 +246,8 @@ namespace Spine {
 					float lb = MathUtils.CosDeg(90 + shearY) * scaleY;
 					float lc = MathUtils.SinDeg(shearX) * scaleX;
 					float ld = MathUtils.SinDeg(90 + shearY) * scaleY;
-					if (data.transformMode != TransformMode.NoScaleOrReflection? pa * pd - pb* pc< 0 : skeleton.flipX != skeleton.flipY) {
-						zb = -zb;
+					if (data.transformMode != TransformMode.NoScaleOrReflection? pa * pd - pb* pc< 0 : skeleton.flipX != skeleton.flipY) {
+						zb = -zb;
 						zd = -zd;
 					}
 					a = za * la + zb * lc;

+ 1 - 1
spine-csharp/src/ExposedList.cs

@@ -1,4 +1,4 @@
-//
+//
 // System.Collections.Generic.List
 //
 // Authors:

+ 2 - 2
spine-unity/Assets/spine-unity/Editor/Menus.cs

@@ -45,7 +45,7 @@ namespace Spine.Unity.Editor {
 			CreateAsset<SkeletonDataAsset>("New SkeletonData");
 		}
 
-		static private void CreateAsset <T> (String name) where T : ScriptableObject {
+		static void CreateAsset<T> (String name) where T : ScriptableObject {
 			var dir = "Assets/";
 			var selected = Selection.activeObject;
 			if (selected != null) {
@@ -70,7 +70,7 @@ namespace Spine.Unity.Editor {
 			CreateSpineGameObject<SkeletonAnimation>("New SkeletonAnimation");
 		}
 
-		static public void CreateSpineGameObject<T> (string name) where T : MonoBehaviour {
+		static void CreateSpineGameObject<T> (string name) where T : MonoBehaviour {
 			var parentGameObject = Selection.activeObject as GameObject;
 			var parentTransform = parentGameObject == null ? null : parentGameObject.transform;
 

+ 1 - 1
spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs

@@ -625,7 +625,7 @@ namespace Spine.Unity.Editor {
 
 		public event Action<string> OnSkinChanged;
 
-		Texture previewTexture = new Texture();
+		Texture previewTexture;
 		PreviewRenderUtility previewRenderUtility;
 		Camera PreviewUtilityCamera {
 			get {

+ 6 - 24
spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs

@@ -37,13 +37,9 @@ namespace Spine.Unity.Modules.AttachmentTools {
 		/// <summary>
 		/// Tries to get the region (image) of a renderable attachment. If the attachment is not renderable, it returns null.</summary>
 		public static AtlasRegion GetRegion (this Attachment attachment) {
-			var regionAttachment = attachment as RegionAttachment;
-			if (regionAttachment != null)
-				return regionAttachment.RendererObject as AtlasRegion;
-
-			var meshAttachment = attachment as MeshAttachment;
-			if (meshAttachment != null)
-				return meshAttachment.RendererObject as AtlasRegion;
+			var renderableAttachment = attachment as IHasRendererObject;
+			if (renderableAttachment != null)
+				return renderableAttachment.RendererObject as AtlasRegion;
 
 			return null;
 		}
@@ -418,7 +414,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
 				var newAttachment = originalAttachment.GetClone(true);
 				if (IsRenderable(newAttachment)) {
 
-					var region = newAttachment.GetAtlasRegion();
+					var region = newAttachment.GetRegion();
 					int existingIndex;
 					if (existingRegions.TryGetValue(region, out existingIndex)) {
 						regionIndexes.Add(existingIndex); // Store the region index for the eventual new attachment.
@@ -503,7 +499,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
 				var newAttachment = kvp.Value.GetClone(true);
 				if (IsRenderable(newAttachment)) {
 
-					var region = newAttachment.GetAtlasRegion();
+					var region = newAttachment.GetRegion();
 					int existingIndex;
 					if (existingRegions.TryGetValue(region, out existingIndex)) {
 						regionIndexes.Add(existingIndex); // Store the region index for the eventual new attachment.
@@ -627,7 +623,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
 		}
 
 		static bool IsRenderable (Attachment a) {
-			return a is RegionAttachment || a is MeshAttachment;
+			return a is IHasRendererObject;
 		}
 
 		/// <summary>
@@ -719,20 +715,6 @@ namespace Spine.Unity.Modules.AttachmentTools {
 			};
 		}
 
-		/// <summary>
-		/// Tries to get the backing AtlasRegion of an attachment if it is renderable. Returns null for non-renderable attachments.</summary>
-		static AtlasRegion GetAtlasRegion (this Attachment a) {
-			var regionAttachment = a as RegionAttachment;
-			if (regionAttachment != null)
-				return (regionAttachment.RendererObject) as AtlasRegion;
-
-			var meshAttachment = a as MeshAttachment;
-			if (meshAttachment != null)
-				return (meshAttachment.RendererObject) as AtlasRegion;
-
-			return null;
-		}
-
 		/// <summary>
 		/// Convenience method for getting the main texture of the material of the page of the region.</summary>
 		static Texture2D GetMainTexture (this AtlasRegion region) {

+ 6 - 9
spine-unity/Assets/spine-unity/SkeletonExtensions.cs

@@ -212,14 +212,11 @@ namespace Spine.Unity {
 		#region Attachments
 		public static Material GetMaterial (this Attachment a) {
 			object rendererObject = null;
-			var regionAttachment = a as RegionAttachment;
-			if (regionAttachment != null)
-				rendererObject = regionAttachment.RendererObject;
-
-			var meshAttachment = a as MeshAttachment;
-			if (meshAttachment != null)
-				rendererObject = meshAttachment.RendererObject;
-
+			var renderableAttachment = a as IHasRendererObject;
+			if (renderableAttachment != null) {
+				rendererObject = renderableAttachment.RendererObject;
+			}
+			
 			if (rendererObject == null)
 				return null;
 			
@@ -297,7 +294,7 @@ namespace Spine {
 		}
 
 		public static bool IsRenderable (this Attachment a) {
-			return a is RegionAttachment || a is MeshAttachment;
+			return a is IHasRendererObject;
 		}
 
 		#region Transform Modes