From 37d569414de7393c660066bad7e26fa79768c053 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 29 Apr 2020 16:08:29 +0200 Subject: [PATCH] [csharp] Minor cleanup: removed unused variable, added null tests to legacy SpriteAttacher class. --- spine-csharp/src/Animation.cs | 1 - .../Scripts/Sample Components/Legacy/SpriteAttacher.cs | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs index 8fff49ba0..e0107fb84 100644 --- a/spine-csharp/src/Animation.cs +++ b/spine-csharp/src/Animation.cs @@ -981,7 +981,6 @@ namespace Spine { public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList firedEvents, float alpha, MixBlend blend, MixDirection direction) { - string attachmentName; Slot slot = skeleton.slots.Items[slotIndex]; if (!slot.bone.active) return; if (direction == MixDirection.Out) { diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs index 7334d8599..40a9856ca 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs @@ -60,6 +60,8 @@ namespace Spine.Unity.Examples { if (applyPMA) { try { + if (sprite == null) + return; sprite.texture.GetPixel(0, 0); } catch (UnityException e) { Debug.LogFormat("Texture of {0} ({1}) is not read/write enabled. SpriteAttacher requires this in order to work with a SkeletonRenderer that renders premultiplied alpha. Please check the texture settings.", sprite.name, sprite.texture.name); @@ -124,7 +126,10 @@ namespace Spine.Unity.Examples { spineSlot = spineSlot ?? skeletonComponent.Skeleton.FindSlot(slot); Shader attachmentShader = applyPMA ? Shader.Find(DefaultPMAShader) : Shader.Find(DefaultStraightAlphaShader); - attachment = applyPMA ? sprite.ToRegionAttachmentPMAClone(attachmentShader) : sprite.ToRegionAttachment(SpriteAttacher.GetPageFor(sprite.texture, attachmentShader)); + if (sprite == null) + attachment = null; + else + attachment = applyPMA ? sprite.ToRegionAttachmentPMAClone(attachmentShader) : sprite.ToRegionAttachment(SpriteAttacher.GetPageFor(sprite.texture, attachmentShader)); } }