Skip to content

Commit

Permalink
[csharp] Minor cleanup: removed unused variable, added null tests to …
Browse files Browse the repository at this point in the history
…legacy SpriteAttacher class.
  • Loading branch information
HaraldCsaszar committed Apr 29, 2020
1 parent a0c0db0 commit 37d5694
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion spine-csharp/src/Animation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,6 @@ public void SetFrame (int frameIndex, float time, String attachmentName) {

public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, MixBlend blend,
MixDirection direction) {
string attachmentName;
Slot slot = skeleton.slots.Items[slotIndex];
if (!slot.bone.active) return;
if (direction == MixDirection.Out) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ void OnValidate () {

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);
Expand Down Expand Up @@ -124,7 +126,10 @@ public void Initialize (bool overwrite = true) {

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));
}
}

Expand Down

0 comments on commit 37d5694

Please sign in to comment.