[csharp] Minor cleanup: removed unused variable, added null tests to legacy SpriteAttacher class.

This commit is contained in:
Harald Csaszar 2020-04-29 16:08:29 +02:00
parent a0c0db0f5a
commit 37d569414d
2 changed files with 6 additions and 2 deletions

View File

@ -981,7 +981,6 @@ namespace Spine {
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) {

View File

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