diff --git a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs
index 511a874fd..6ddf09547 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.
@@ -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..9b64e75a1 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;