diff --git a/spine-csharp/src/Attachments/Attachment.cs b/spine-csharp/src/Attachments/Attachment.cs
index 7f033187a..2761735e0 100644
--- a/spine-csharp/src/Attachments/Attachment.cs
+++ b/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; }
+ }
}
diff --git a/spine-csharp/src/Attachments/MeshAttachment.cs b/spine-csharp/src/Attachments/MeshAttachment.cs
index fe0ca29a4..66ecf8ca7 100644
--- a/spine-csharp/src/Attachments/MeshAttachment.cs
+++ b/spine-csharp/src/Attachments/MeshAttachment.cs
@@ -32,7 +32,7 @@ using System;
namespace Spine {
/// Attachment that displays a texture region using a mesh.
- 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; }
diff --git a/spine-csharp/src/Attachments/RegionAttachment.cs b/spine-csharp/src/Attachments/RegionAttachment.cs
index e5e1064ae..cb477d901 100644
--- a/spine-csharp/src/Attachments/RegionAttachment.cs
+++ b/spine-csharp/src/Attachments/RegionAttachment.cs
@@ -32,7 +32,7 @@ using System;
namespace Spine {
/// Attachment that displays a texture region.
- 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; } }
diff --git a/spine-csharp/src/Bone.cs b/spine-csharp/src/Bone.cs
index 6a1ef642c..8a68cc203 100644
--- a/spine-csharp/src/Bone.cs
+++ b/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;
diff --git a/spine-csharp/src/ExposedList.cs b/spine-csharp/src/ExposedList.cs
index 6943448da..e76086a28 100644
--- a/spine-csharp/src/ExposedList.cs
+++ b/spine-csharp/src/ExposedList.cs
@@ -1,4 +1,4 @@
-//
+//
// System.Collections.Generic.List
//
// Authors:
diff --git a/spine-unity/Assets/spine-unity/Editor/Menus.cs b/spine-unity/Assets/spine-unity/Editor/Menus.cs
index 5ff96a16a..1b18124fd 100644
--- a/spine-unity/Assets/spine-unity/Editor/Menus.cs
+++ b/spine-unity/Assets/spine-unity/Editor/Menus.cs
@@ -45,7 +45,7 @@ namespace Spine.Unity.Editor {
CreateAsset("New SkeletonData");
}
- static private void CreateAsset (String name) where T : ScriptableObject {
+ static void CreateAsset (String name) where T : ScriptableObject {
var dir = "Assets/";
var selected = Selection.activeObject;
if (selected != null) {
@@ -70,7 +70,7 @@ namespace Spine.Unity.Editor {
CreateSpineGameObject("New SkeletonAnimation");
}
- static public void CreateSpineGameObject (string name) where T : MonoBehaviour {
+ static void CreateSpineGameObject (string name) where T : MonoBehaviour {
var parentGameObject = Selection.activeObject as GameObject;
var parentTransform = parentGameObject == null ? null : parentGameObject.transform;
diff --git a/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs b/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs
index 6f7aecf52..0ae00c3ce 100644
--- a/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs
+++ b/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs
@@ -625,7 +625,7 @@ namespace Spine.Unity.Editor {
public event Action OnSkinChanged;
- Texture previewTexture = new Texture();
+ Texture previewTexture;
PreviewRenderUtility previewRenderUtility;
Camera PreviewUtilityCamera {
get {
diff --git a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs
index a1e2bc9ec..265e9c7d9 100644
--- a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs
+++ b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs
@@ -37,13 +37,9 @@ namespace Spine.Unity.Modules.AttachmentTools {
///
/// Tries to get the region (image) of a renderable attachment. If the attachment is not renderable, it returns null.
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;
}
///
@@ -719,20 +715,6 @@ namespace Spine.Unity.Modules.AttachmentTools {
};
}
- ///
- /// Tries to get the backing AtlasRegion of an attachment if it is renderable. Returns null for non-renderable attachments.
- 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;
- }
-
///
/// Convenience method for getting the main texture of the material of the page of the region.
static Texture2D GetMainTexture (this AtlasRegion region) {
diff --git a/spine-unity/Assets/spine-unity/SkeletonExtensions.cs b/spine-unity/Assets/spine-unity/SkeletonExtensions.cs
index a3d97551a..b2760574c 100644
--- a/spine-unity/Assets/spine-unity/SkeletonExtensions.cs
+++ b/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