Browse Source

Merged with master, resolved conflicts

badlogic 8 years ago
parent
commit
1ad8e6b63c

+ 1 - 1
spine-as3/spine-as3/src/spine/SkeletonJson.as

@@ -719,7 +719,7 @@ public class SkeletonJson {
 	}
 
 	static private function toColor (hexString:String, colorIndex:int) : Number {
-		if (hexString.length != 8) throw new ArgumentError("Color hexidecimal length must be 8, recieved: " + hexString);
+		if (hexString.length != 8) throw new ArgumentError("Color hexidecimal length must be 8, received: " + hexString);
 		return parseInt(hexString.substring(colorIndex * 2, colorIndex * 2 + 2), 16) / 255;
 	}
 

+ 1 - 1
spine-csharp/src/Bone.cs

@@ -262,7 +262,7 @@ namespace Spine {
 				a = -a;
 				b = -b;
 			}
-			if (skeleton.flipY) {
+			if (skeleton.flipY != Bone.yDown) {
 				c = -c;
 				d = -d;
 			}

+ 2 - 2
spine-ts/README.md

@@ -22,9 +22,9 @@ spine-ts works with data exported from Spine 3.6.xx
 
 spine-ts WebGL & Widget backends supports all Spine features. 
 
-The spine-ts Canvas backend does not support color tinting, mesh attachments or shearing. Mesh attachments are supported by setting `spine.canvas.SkeletonRenderer.useTriangleRendering` to true. Note that this method is slow and may lead to artifacts on some browsers. 
+spine-ts Canvas does not support color tinting and mesh attachments. Only the alpha channel from tint colors is applied. Experimental support for mesh attachments can be enabled by setting `spine.canvas.SkeletonRenderer.useTriangleRendering` to true. Note that this method is slow and may lead to artifacts on some browsers. 
 
-The spine-ts THREE.JS backend does not support color tinting and blend modes. The THREE.JS backend provides `SkeletonMesh.zOffset` to avoid z-fighting. Adjust to your near/far plane settings.
+spine-ts THREE.JS does not support color tinting and blend modes. The THREE.JS backend provides `SkeletonMesh.zOffset` to avoid z-fighting. Adjust to your near/far plane settings.
 
 spine-ts does not yet support loading the binary format.
 

+ 26 - 23
spine-ts/build/spine-all.js

@@ -228,45 +228,48 @@ var spine;
 				var drawOrder = skeleton.drawOrder;
 				if (this.debugRendering)
 					ctx.strokeStyle = "green";
+				ctx.save();
 				for (var i = 0, n = drawOrder.length; i < n; i++) {
 					var slot = drawOrder[i];
 					var attachment = slot.getAttachment();
+					var regionAttachment = null;
 					var region = null;
 					var image = null;
-					var vertices = this.vertices;
 					if (attachment instanceof spine.RegionAttachment) {
-						var regionAttachment = attachment;
-						vertices = this.computeRegionVertices(slot, regionAttachment, false);
+						regionAttachment = attachment;
 						region = regionAttachment.region;
-						image = (region).texture.getImage();
+						image = region.texture.getImage();
 					}
 					else
 						continue;
+					var skeleton_1 = slot.bone.skeleton;
+					var skeletonColor = skeleton_1.color;
+					var slotColor = slot.color;
+					var regionColor = regionAttachment.color;
+					var alpha = skeletonColor.a * slotColor.a * regionColor.a;
+					var color = this.tempColor;
+					color.set(skeletonColor.r * slotColor.r * regionColor.r, skeletonColor.g * slotColor.g * regionColor.g, skeletonColor.b * slotColor.b * regionColor.b, alpha);
 					var att = attachment;
 					var bone = slot.bone;
-					var x = vertices[0];
-					var y = vertices[1];
-					var rotation = (bone.getWorldRotationX() - att.rotation) * Math.PI / 180;
-					var xx = vertices[24] - vertices[0];
-					var xy = vertices[25] - vertices[1];
-					var yx = vertices[8] - vertices[0];
-					var yy = vertices[9] - vertices[1];
-					var w = Math.sqrt(xx * xx + xy * xy), h = -Math.sqrt(yx * yx + yy * yy);
-					ctx.translate(x, y);
-					ctx.rotate(rotation);
-					if (region.rotate) {
-						ctx.rotate(Math.PI / 2);
-						ctx.drawImage(image, region.x, region.y, region.height, region.width, 0, 0, h, -w);
-						ctx.rotate(-Math.PI / 2);
-					}
-					else {
-						ctx.drawImage(image, region.x, region.y, region.width, region.height, 0, 0, w, h);
+					var w = region.width;
+					var h = region.height;
+					ctx.save();
+					ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
+					ctx.translate(attachment.offset[0], attachment.offset[1]);
+					ctx.rotate(attachment.rotation * Math.PI / 180);
+					ctx.scale(attachment.scaleX, attachment.scaleY);
+					ctx.translate(w / 2, h / 2);
+					ctx.scale(1, -1);
+					ctx.translate(-w / 2, -h / 2);
+					if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) {
+						ctx.globalAlpha = color.a;
 					}
+					ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
 					if (this.debugRendering)
 						ctx.strokeRect(0, 0, w, h);
-					ctx.rotate(-rotation);
-					ctx.translate(-x, -y);
+					ctx.restore();
 				}
+				ctx.restore();
 			};
 			SkeletonRenderer.prototype.drawTriangles = function (skeleton) {
 				var blendMode = null;

File diff suppressed because it is too large
+ 0 - 0
spine-ts/build/spine-all.js.map


+ 26 - 23
spine-ts/build/spine-canvas.js

@@ -228,45 +228,48 @@ var spine;
 				var drawOrder = skeleton.drawOrder;
 				if (this.debugRendering)
 					ctx.strokeStyle = "green";
+				ctx.save();
 				for (var i = 0, n = drawOrder.length; i < n; i++) {
 					var slot = drawOrder[i];
 					var attachment = slot.getAttachment();
+					var regionAttachment = null;
 					var region = null;
 					var image = null;
-					var vertices = this.vertices;
 					if (attachment instanceof spine.RegionAttachment) {
-						var regionAttachment = attachment;
-						vertices = this.computeRegionVertices(slot, regionAttachment, false);
+						regionAttachment = attachment;
 						region = regionAttachment.region;
-						image = (region).texture.getImage();
+						image = region.texture.getImage();
 					}
 					else
 						continue;
+					var skeleton_1 = slot.bone.skeleton;
+					var skeletonColor = skeleton_1.color;
+					var slotColor = slot.color;
+					var regionColor = regionAttachment.color;
+					var alpha = skeletonColor.a * slotColor.a * regionColor.a;
+					var color = this.tempColor;
+					color.set(skeletonColor.r * slotColor.r * regionColor.r, skeletonColor.g * slotColor.g * regionColor.g, skeletonColor.b * slotColor.b * regionColor.b, alpha);
 					var att = attachment;
 					var bone = slot.bone;
-					var x = vertices[0];
-					var y = vertices[1];
-					var rotation = (bone.getWorldRotationX() - att.rotation) * Math.PI / 180;
-					var xx = vertices[24] - vertices[0];
-					var xy = vertices[25] - vertices[1];
-					var yx = vertices[8] - vertices[0];
-					var yy = vertices[9] - vertices[1];
-					var w = Math.sqrt(xx * xx + xy * xy), h = -Math.sqrt(yx * yx + yy * yy);
-					ctx.translate(x, y);
-					ctx.rotate(rotation);
-					if (region.rotate) {
-						ctx.rotate(Math.PI / 2);
-						ctx.drawImage(image, region.x, region.y, region.height, region.width, 0, 0, h, -w);
-						ctx.rotate(-Math.PI / 2);
-					}
-					else {
-						ctx.drawImage(image, region.x, region.y, region.width, region.height, 0, 0, w, h);
+					var w = region.width;
+					var h = region.height;
+					ctx.save();
+					ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
+					ctx.translate(attachment.offset[0], attachment.offset[1]);
+					ctx.rotate(attachment.rotation * Math.PI / 180);
+					ctx.scale(attachment.scaleX, attachment.scaleY);
+					ctx.translate(w / 2, h / 2);
+					ctx.scale(1, -1);
+					ctx.translate(-w / 2, -h / 2);
+					if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) {
+						ctx.globalAlpha = color.a;
 					}
+					ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
 					if (this.debugRendering)
 						ctx.strokeRect(0, 0, w, h);
-					ctx.rotate(-rotation);
-					ctx.translate(-x, -y);
+					ctx.restore();
 				}
+				ctx.restore();
 			};
 			SkeletonRenderer.prototype.drawTriangles = function (skeleton) {
 				var blendMode = null;

File diff suppressed because it is too large
+ 0 - 0
spine-ts/build/spine-canvas.js.map


+ 37 - 58
spine-ts/canvas/example/assets/spineboy.atlas

@@ -5,141 +5,120 @@ format: RGBA8888
 filter: Linear,Linear
 repeat: none
 eye_indifferent
-  rotate: true
-  xy: 648, 629
+  rotate: false
+  xy: 275, 349
   size: 93, 89
   orig: 93, 89
   offset: 0, 0
   index: -1
 eye_surprised
-  rotate: true
-  xy: 233, 179
+  rotate: false
+  xy: 214, 125
   size: 93, 89
   orig: 93, 89
   offset: 0, 0
   index: -1
 front_bracer
   rotate: false
-  xy: 245, 2
+  xy: 678, 774
   size: 58, 80
   orig: 58, 80
   offset: 0, 0
   index: -1
 front_fist_closed
   rotate: false
-  xy: 168, 45
+  xy: 944, 940
   size: 75, 82
   orig: 75, 82
   offset: 0, 0
   index: -1
 front_fist_open
   rotate: false
-  xy: 844, 646
+  xy: 132, 28
   size: 86, 87
   orig: 86, 87
   offset: 0, 0
   index: -1
 front_foot
-  rotate: true
-  xy: 310, 326
+  rotate: false
+  xy: 550, 785
   size: 126, 69
   orig: 126, 69
   offset: 0, 0
   index: -1
 front_foot_bend1
-  rotate: true
-  xy: 951, 894
+  rotate: false
+  xy: 2, 45
   size: 128, 70
   orig: 128, 70
   offset: 0, 0
   index: -1
 front_foot_bend2
   rotate: false
-  xy: 2, 33
+  xy: 729, 929
   size: 108, 93
   orig: 108, 93
   offset: 0, 0
   index: -1
 front_shin
-  rotate: true
-  xy: 739, 735
+  rotate: false
+  xy: 466, 670
   size: 82, 184
   orig: 82, 184
   offset: 0, 0
   index: -1
 front_thigh
   rotate: false
-  xy: 381, 340
+  xy: 281, 235
   size: 48, 112
   orig: 48, 112
   offset: 0, 0
   index: -1
 front_upper_arm
   rotate: false
-  xy: 112, 29
+  xy: 220, 26
   size: 54, 97
   orig: 54, 97
   offset: 0, 0
   index: -1
 goggles
   rotate: false
-  xy: 156, 454
+  xy: 466, 856
   size: 261, 166
   orig: 261, 166
   offset: 0, 0
   index: -1
 gun
   rotate: false
-  xy: 739, 819
+  xy: 2, 117
   size: 210, 203
   orig: 210, 203
   offset: 0, 0
   index: -1
 head
   rotate: false
-  xy: 466, 724
+  xy: 2, 322
   size: 271, 298
   orig: 271, 298
   offset: 0, 0
   index: -1
-hoverboard_board
-  rotate: true
-  xy: 2, 128
-  size: 492, 152
-  orig: 492, 152
-  offset: 0, 0
-  index: -1
-hoverboard_thruster
-  rotate: false
-  xy: 602, 558
-  size: 60, 64
-  orig: 60, 64
-  offset: 0, 0
-  index: -1
-hoverglow_small
-  rotate: true
-  xy: 156, 178
-  size: 274, 75
-  orig: 274, 75
-  offset: 0, 0
-  index: -1
 mouth_grind
-  rotate: true
-  xy: 951, 799
+  rotate: false
+  xy: 844, 878
   size: 93, 59
   orig: 93, 59
   offset: 0, 0
   index: -1
 mouth_oooo
-  rotate: true
-  xy: 245, 84
+  rotate: false
+  xy: 550, 656
   size: 93, 59
   orig: 93, 59
   offset: 0, 0
   index: -1
 mouth_smile
   rotate: false
-  xy: 925, 738
+  xy: 738, 806
   size: 93, 59
   orig: 93, 59
   offset: 0, 0
@@ -153,63 +132,63 @@ muzzle
   index: -1
 neck
   rotate: false
-  xy: 168, 2
+  xy: 2, 2
   size: 36, 41
   orig: 36, 41
   offset: 0, 0
   index: -1
 rear_bracer
   rotate: false
-  xy: 932, 664
+  xy: 276, 51
   size: 56, 72
   orig: 56, 72
   offset: 0, 0
   index: -1
 rear_foot
   rotate: false
-  xy: 487, 562
+  xy: 729, 867
   size: 113, 60
   orig: 113, 60
   offset: 0, 0
   index: -1
 rear_foot_bend1
-  rotate: true
-  xy: 419, 503
+  rotate: false
+  xy: 550, 717
   size: 117, 66
   orig: 117, 66
   offset: 0, 0
   index: -1
 rear_foot_bend2
   rotate: false
-  xy: 739, 650
+  xy: 839, 939
   size: 103, 83
   orig: 103, 83
   offset: 0, 0
   index: -1
 rear_shin
   rotate: false
-  xy: 233, 274
+  xy: 375, 442
   size: 75, 178
   orig: 75, 178
   offset: 0, 0
   index: -1
 rear_thigh
-  rotate: true
-  xy: 487, 495
+  rotate: false
+  xy: 214, 216
   size: 65, 104
   orig: 65, 104
   offset: 0, 0
   index: -1
 rear_upper_arm
-  rotate: true
-  xy: 156, 129
+  rotate: false
+  xy: 331, 260
   size: 47, 87
   orig: 47, 87
   offset: 0, 0
   index: -1
 torso
-  rotate: true
-  xy: 466, 624
+  rotate: false
+  xy: 275, 440
   size: 98, 180
   orig: 98, 180
   offset: 0, 0

File diff suppressed because it is too large
+ 0 - 2412
spine-ts/canvas/example/assets/spineboy.json


BIN
spine-ts/canvas/example/assets/spineboy.png


+ 15 - 4
spine-ts/canvas/example/index.html

@@ -17,6 +17,9 @@ var assetManager;
 var skeleton, state, bounds;
 var skeletonRenderer;
 
+var skelName = "spineboy";
+var animName = "test";
+
 function init () {
 	canvas = document.getElementById("canvas");
 	canvas.width = window.innerWidth;
@@ -31,16 +34,16 @@ function init () {
 
 	assetManager = new spine.canvas.AssetManager();
 
-	assetManager.loadText("assets/spineboy.json");
-	assetManager.loadText("assets/spineboy.atlas");
-	assetManager.loadTexture("assets/spineboy.png");
+	assetManager.loadText("assets/" + skelName + ".json");
+	assetManager.loadText("assets/" + skelName + ".atlas");
+	assetManager.loadTexture("assets/" + skelName + ".png");
 
 	requestAnimationFrame(load);
 }
 
 function load () {
 	if (assetManager.isLoadingComplete()) {
-		var data = loadSkeleton("spineboy", "walk", "default");
+		var data = loadSkeleton(skelName, animName, "default");
 		skeleton = data.skeleton;
 		state = data.state;
 		bounds = data.bounds;
@@ -122,6 +125,14 @@ function render () {
 	skeleton.updateWorldTransform();
 	skeletonRenderer.draw(skeleton);
 
+	context.strokeStyle = "green";
+	context.beginPath();
+	context.moveTo(-1000, 0);
+	context.lineTo(1000, 0);
+	context.moveTo(0, -1000);
+	context.lineTo(0, 1000);
+	context.stroke();
+
 	requestAnimationFrame(render);
 }
 

+ 36 - 23
spine-ts/canvas/src/SkeletonRenderer.ts

@@ -55,43 +55,56 @@ module spine.canvas {
 
 			if (this.debugRendering) ctx.strokeStyle = "green";
 
+			ctx.save();
 			for (let i = 0, n = drawOrder.length; i < n; i++) {
 				let slot = drawOrder[i];
 				let attachment = slot.getAttachment();
+				let regionAttachment: RegionAttachment = null;
 				let region: TextureAtlasRegion = null;
 				let image: HTMLImageElement = null;
-				let vertices: ArrayLike<number> = this.vertices;
+
 				if (attachment instanceof RegionAttachment) {
-					let regionAttachment = <RegionAttachment>attachment;
-					vertices = this.computeRegionVertices(slot, regionAttachment, false);
+					regionAttachment = <RegionAttachment>attachment;
 					region = <TextureAtlasRegion>regionAttachment.region;
-					image = (<CanvasTexture>(region).texture).getImage();
-
+					image = (<CanvasTexture>region.texture).getImage();
 				} else continue;
 
+				let skeleton = slot.bone.skeleton;
+				let skeletonColor = skeleton.color;
+				let slotColor = slot.color;
+				let regionColor = regionAttachment.color;
+				let alpha = skeletonColor.a * slotColor.a * regionColor.a;
+				let color = this.tempColor;
+				color.set(skeletonColor.r * slotColor.r * regionColor.r,
+					skeletonColor.g * slotColor.g * regionColor.g,
+					skeletonColor.b * slotColor.b * regionColor.b,
+					alpha);
+
 				let att = <RegionAttachment>attachment;
 				let bone = slot.bone;
-				let x = vertices[0];
-				let y = vertices[1];
-				let rotation = (bone.getWorldRotationX() - att.rotation) * Math.PI / 180;
-				let xx = vertices[24] - vertices[0];
-				let xy = vertices[25] - vertices[1];
-				let yx = vertices[8] - vertices[0];
-				let yy = vertices[9] - vertices[1];
-				let w = Math.sqrt(xx * xx + xy * xy), h = -Math.sqrt(yx * yx + yy * yy);
-				ctx.translate(x, y);
-				ctx.rotate(rotation);
-				if (region.rotate) {
-					ctx.rotate(Math.PI / 2);
-					ctx.drawImage(image, region.x, region.y, region.height, region.width, 0, 0, h, -w);
-					ctx.rotate(-Math.PI / 2);
-				} else {
-					ctx.drawImage(image, region.x, region.y, region.width, region.height, 0, 0, w, h);
+				let w = region.width;
+				let h = region.height;
+				ctx.save();
+				ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
+				ctx.translate(attachment.offset[0], attachment.offset[1]);
+				ctx.rotate(attachment.rotation * Math.PI / 180);
+				ctx.scale(attachment.scaleX, attachment.scaleY);
+				ctx.translate(w / 2, h / 2);
+				ctx.scale(1, -1);
+				ctx.translate(-w / 2, -h / 2);
+				if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) {
+					ctx.globalAlpha = color.a;
+					// experimental tinting via compositing, doesn't work
+					// ctx.globalCompositeOperation = "source-atop";
+					// ctx.fillStyle = "rgba(" + (color.r * 255 | 0) + ", " + (color.g * 255 | 0)  + ", " + (color.b * 255 | 0) + ", " + color.a + ")";
+					// ctx.fillRect(0, 0, w, h);
 				}
+				ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
 				if (this.debugRendering) ctx.strokeRect(0, 0, w, h);
-				ctx.rotate(-rotation);
-				ctx.translate(-x, -y);
+				ctx.restore();
 			}
+
+			ctx.restore();
 		}
 
 		private drawTriangles (skeleton: Skeleton) {

+ 4 - 0
spine-unity/Assets/spine-unity/Modules/CustomMaterials/Editor/SkeletonRendererCustomMaterialsInspector.cs

@@ -28,6 +28,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
+#define SPINE_OPTIONAL_MATERIALOVERRIDE
+
 // Contributed by: Lost Polygon
 
 using System;
@@ -136,7 +138,9 @@ namespace Spine.Unity.Editor {
 
 			if (SpineInspectorUtility.LargeCenteredButton(new GUIContent("Clear and Reapply Changes", "Removes all non-serialized overrides in the SkeletonRenderer and reapplies the overrides on this component."))) {
 				if (skeletonRenderer != null) {
+					#if SPINE_OPTIONAL_MATERIALOVERRIDE
 					skeletonRenderer.CustomMaterialOverride.Clear();
+					#endif
 					skeletonRenderer.CustomSlotMaterials.Clear();
 					RemoveCustomMaterials();
 					SetCustomMaterials();

+ 10 - 3
spine-unity/Assets/spine-unity/Modules/CustomMaterials/SkeletonRendererCustomMaterials.cs

@@ -28,6 +28,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
+#define SPINE_OPTIONAL_MATERIALOVERRIDE
+
 // Contributed by: Lost Polygon
 
 using System;
@@ -40,8 +42,8 @@ namespace Spine.Unity.Modules {
 
 		#region Inspector
 		public SkeletonRenderer skeletonRenderer;
-		[SerializeField] List<SlotMaterialOverride> customSlotMaterials = new List<SlotMaterialOverride>();
-		[SerializeField] List<AtlasMaterialOverride> customMaterialOverrides = new List<AtlasMaterialOverride>();
+		[SerializeField] protected List<SlotMaterialOverride> customSlotMaterials = new List<SlotMaterialOverride>();
+		[SerializeField] protected List<AtlasMaterialOverride> customMaterialOverrides = new List<AtlasMaterialOverride>();
 
 		#if UNITY_EDITOR
 		void Reset () {
@@ -115,6 +117,7 @@ namespace Spine.Unity.Modules {
 				return;
 			}
 
+			#if SPINE_OPTIONAL_MATERIALOVERRIDE
 			for (int i = 0; i < customMaterialOverrides.Count; i++) {
 				AtlasMaterialOverride atlasMaterialOverride = customMaterialOverrides[i];
 				if (atlasMaterialOverride.overrideDisabled)
@@ -122,6 +125,7 @@ namespace Spine.Unity.Modules {
 
 				skeletonRenderer.CustomMaterialOverride[atlasMaterialOverride.originalMaterial] = atlasMaterialOverride.replacementMaterial;
 			}
+			#endif
 		}
 
 		void RemoveCustomMaterialOverrides () {
@@ -130,18 +134,21 @@ namespace Spine.Unity.Modules {
 				return;
 			}
 
+			#if SPINE_OPTIONAL_MATERIALOVERRIDE
 			for (int i = 0; i < customMaterialOverrides.Count; i++) {
 				AtlasMaterialOverride atlasMaterialOverride = customMaterialOverrides[i];
 				Material currentMaterial;
+
 				if (!skeletonRenderer.CustomMaterialOverride.TryGetValue(atlasMaterialOverride.originalMaterial, out currentMaterial))
 					continue;
-
+				
 				// Do not revert the material if it was changed by something else
 				if (currentMaterial != atlasMaterialOverride.replacementMaterial)
 					continue;
 
 				skeletonRenderer.CustomMaterialOverride.Remove(atlasMaterialOverride.originalMaterial);
 			}
+			#endif
 		}
 			
 		// OnEnable applies the overrides at runtime, and when the editor loads.

+ 19 - 1
spine-unity/Assets/spine-unity/Modules/SkeletonRenderSeparator/SkeletonRenderSeparator.cs

@@ -28,6 +28,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
+#define SPINE_OPTIONAL_RENDEROVERRIDE
+
 using UnityEngine;
 using System.Collections.Generic;
 using Spine.Unity;
@@ -45,8 +47,10 @@ namespace Spine.Unity.Modules {
 		public SkeletonRenderer SkeletonRenderer {
 			get { return skeletonRenderer; }
 			set {
+				#if SPINE_OPTIONAL_RENDEROVERRIDE
 				if (skeletonRenderer != null)
 					skeletonRenderer.GenerateMeshOverride -= HandleRender;
+				#endif
 				
 				skeletonRenderer = value;
 				this.enabled = false; // Disable if nulled.
@@ -72,8 +76,11 @@ namespace Spine.Unity.Modules {
 			if (copiedBlock == null) copiedBlock = new MaterialPropertyBlock();	
 			mainMeshRenderer = skeletonRenderer.GetComponent<MeshRenderer>();
 
+			#if SPINE_OPTIONAL_RENDEROVERRIDE
 			skeletonRenderer.GenerateMeshOverride -= HandleRender;
 			skeletonRenderer.GenerateMeshOverride += HandleRender;
+			#endif
+
 
 			#if UNITY_5_4_OR_NEWER
 			if (copyMeshRendererFlags) {
@@ -109,7 +116,9 @@ namespace Spine.Unity.Modules {
 
 		void OnDisable () {
 			if (skeletonRenderer == null) return;
+			#if SPINE_OPTIONAL_RENDEROVERRIDE
 			skeletonRenderer.GenerateMeshOverride -= HandleRender;
+			#endif
 
 			#if UNITY_EDITOR
 			skeletonRenderer.LateUpdate();
@@ -132,9 +141,14 @@ namespace Spine.Unity.Modules {
 			var submeshInstructionsItems = submeshInstructions.Items;
 			int lastSubmeshInstruction = submeshInstructions.Count - 1;
 
-
+			#if SPINE_OPTIONAL_NORMALS
 			bool addNormals = skeletonRenderer.calculateNormals;
+			#endif
+
+			#if SPINE_OPTIONAL_SOLVETANGENTS
 			bool addTangents = skeletonRenderer.calculateTangents;
+			#endif
+
 			bool pmaVertexColors = skeletonRenderer.pmaVertexColors;
 
 			int rendererIndex = 0;
@@ -143,8 +157,12 @@ namespace Spine.Unity.Modules {
 				if (submeshInstructionsItems[si].forceSeparate || si == lastSubmeshInstruction) {
 					// Apply properties
 					var meshGenerator = currentRenderer.MeshGenerator;
+					#if SPINE_OPTIONAL_NORMALS
 					meshGenerator.AddNormals = addNormals;
+					#endif
+					#if SPINE_OPTIONAL_SOLVETANGENTS
 					meshGenerator.AddTangents = addTangents;
+					#endif
 					meshGenerator.PremultiplyVertexColors = pmaVertexColors;
 					if (copyPropertyBlock)
 						currentRenderer.SetPropertyBlock(copiedBlock);

+ 9 - 1
spine-unity/Assets/spine-unity/SkeletonRenderer.cs

@@ -303,7 +303,11 @@ namespace Spine.Unity {
 				// Slot with a separator/new material will become the starting slot of the next new instruction.
 				bool forceSeparate = (hasSeparators && separatorSlots.Contains(slot));
 				if (noRender) {
-					if (forceSeparate && vertexCount > 0 && this.generateMeshOverride != null) {
+					if (forceSeparate && vertexCount > 0
+						#if SPINE_OPTIONAL_RENDEROVERRIDE
+						&& this.generateMeshOverride != null
+						#endif
+					) {
 						workingSubmeshInstructions.Add(
 							new Spine.Unity.MeshGeneration.SubmeshInstruction {
 								skeleton = this.skeleton,
@@ -411,13 +415,17 @@ namespace Spine.Unity {
 				ArraysMeshGenerator.EnsureSize(vertexCount, ref this.uv2);
 				ArraysMeshGenerator.EnsureSize(vertexCount, ref this.uv3);
 			}
+
 			#if SPINE_OPTIONAL_NORMALS
+			bool vertexCountIncreased = ArraysMeshGenerator.EnsureSize(vertexCount, ref this.vertices, ref this.uvs, ref this.colors);
 			if (vertexCountIncreased && calculateNormals) {
 				Vector3[] localNormals = this.normals = new Vector3[vertexCount];
 				Vector3 normal = new Vector3(0, 0, -1);
 				for (int i = 0; i < vertexCount; i++)
 					localNormals[i] = normal;
 			}
+			#else
+			ArraysMeshGenerator.EnsureSize(vertexCount, ref this.vertices, ref this.uvs, ref this.colors);
 			#endif
 
 			Vector3 meshBoundsMin;

Some files were not shown because too many files changed in this diff