|
@@ -37,13 +37,9 @@ namespace Spine.Unity.Modules.AttachmentTools {
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Tries to get the region (image) of a renderable attachment. If the attachment is not renderable, it returns null.</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) {
|
|
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;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -418,7 +414,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
|
|
var newAttachment = originalAttachment.GetClone(true);
|
|
var newAttachment = originalAttachment.GetClone(true);
|
|
if (IsRenderable(newAttachment)) {
|
|
if (IsRenderable(newAttachment)) {
|
|
|
|
|
|
- var region = newAttachment.GetAtlasRegion();
|
|
|
|
|
|
+ var region = newAttachment.GetRegion();
|
|
int existingIndex;
|
|
int existingIndex;
|
|
if (existingRegions.TryGetValue(region, out existingIndex)) {
|
|
if (existingRegions.TryGetValue(region, out existingIndex)) {
|
|
regionIndexes.Add(existingIndex); // Store the region index for the eventual new attachment.
|
|
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);
|
|
var newAttachment = kvp.Value.GetClone(true);
|
|
if (IsRenderable(newAttachment)) {
|
|
if (IsRenderable(newAttachment)) {
|
|
|
|
|
|
- var region = newAttachment.GetAtlasRegion();
|
|
|
|
|
|
+ var region = newAttachment.GetRegion();
|
|
int existingIndex;
|
|
int existingIndex;
|
|
if (existingRegions.TryGetValue(region, out existingIndex)) {
|
|
if (existingRegions.TryGetValue(region, out existingIndex)) {
|
|
regionIndexes.Add(existingIndex); // Store the region index for the eventual new attachment.
|
|
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) {
|
|
static bool IsRenderable (Attachment a) {
|
|
- return a is RegionAttachment || a is MeshAttachment;
|
|
|
|
|
|
+ return a is IHasRendererObject;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <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>
|
|
/// <summary>
|
|
/// Convenience method for getting the main texture of the material of the page of the region.</summary>
|
|
/// Convenience method for getting the main texture of the material of the page of the region.</summary>
|
|
static Texture2D GetMainTexture (this AtlasRegion region) {
|
|
static Texture2D GetMainTexture (this AtlasRegion region) {
|