mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[unity] Use IHasRendererObject.
This commit is contained in:
parent
f6a98b0f43
commit
4e3cf15acb
@ -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.
|
||||
@ -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) {
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user