Преглед на файлове

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

Harald Csaszar преди 5 години
родител
ревизия
37d569414d
променени са 2 файла, в които са добавени 6 реда и са изтрити 2 реда
  1. 0 1
      spine-csharp/src/Animation.cs
  2. 6 1
      spine-unity/Assets/Spine Examples/Scripts/Sample Components/Legacy/SpriteAttacher.cs

+ 0 - 1
spine-csharp/src/Animation.cs

@@ -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) {

+ 6 - 1
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));
 			}
 		}