Browse Source

Merged origin 3.6 with local 3.6 manually.

badlogic 8 years ago
parent
commit
fc06686080
27 changed files with 600 additions and 103 deletions
  1. 2 0
      CHANGELOG.md
  2. 2 0
      spine-c/spine-c/src/spine/Bone.c
  3. 31 15
      spine-csharp/src/Animation.cs
  4. 1 5
      spine-csharp/src/AnimationState.cs
  5. 0 1
      spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/VertexEffectTest.java
  6. 11 16
      spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java
  7. 1 5
      spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java
  8. 1 1
      spine-ts/build/spine-all.js
  9. 1 1
      spine-ts/build/spine-canvas.js
  10. 1 1
      spine-ts/build/spine-core.js
  11. 1 1
      spine-ts/build/spine-threejs.js
  12. 1 1
      spine-ts/build/spine-webgl.js
  13. 1 1
      spine-ts/build/spine-widget.js
  14. 1 1
      spine-ts/core/src/SkeletonClipping.ts
  15. 312 0
      spine-unity/Assets/Examples/Other Examples/VertexEffect.unity
  16. 8 0
      spine-unity/Assets/Examples/Other Examples/VertexEffect.unity.meta
  17. 9 0
      spine-unity/Assets/Examples/Scripts/Sample Components/Sample VertexEffects.meta
  18. 85 0
      spine-unity/Assets/Examples/Scripts/Sample Components/Sample VertexEffects/JitterEffectExample.cs
  19. 12 0
      spine-unity/Assets/Examples/Scripts/Sample Components/Sample VertexEffects/JitterEffectExample.cs.meta
  20. 48 35
      spine-unity/Assets/spine-unity/Asset Types/Editor/SkeletonDataAssetInspector.cs
  21. 18 6
      spine-unity/Assets/spine-unity/BoneFollower.cs
  22. 1 1
      spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs
  23. 31 6
      spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs
  24. 1 1
      spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/Editor/BoundingBoxFollowerInspector.cs
  25. 10 3
      spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs
  26. 9 1
      spine-unity/Assets/spine-unity/Modules/TK2D/SpriteCollectionAttachmentLoader.cs
  27. 1 1
      spine-unity/Assets/spine-unity/SkeletonRenderer.cs

+ 2 - 0
CHANGELOG.md

@@ -216,6 +216,7 @@
  * Improved performance by using `DYNAMIC_DRAW` for vertex buffer objects and fixing bug that copied to much data to the GPU each frame in `PolygonBatcher`/`Mesh`.
  * Added two color tinting support, enabled by default. You can disable it via the constructors of `SceneRenderer`, `SkeletonRenderer`and `PolygonBatcher`. Note that you will need to use a shader created via `Shader.newTwoColoredTexturedShader` shader with `SkeletonRenderer` and `PolygonBatcher` if two color tinting is enabled.
  * Added clipping support
+ * Added `VertexEffect` interface, instances of which can be set on `SkeletonRenderer`. Allows to modify vertices before submitting them to GPU. See `SwirlEffect`, `JitterEffect`, and the example which allows to set effects.
 
 ### Canvas backend
  * Fixed renderer to work for 3.6 changes. Sadly, we can't support two color tinting via the Canvas API.
@@ -225,6 +226,7 @@
 ### Three.js backend
  * Fixed renderer to work with 3.6 changes. Two color tinting is not supported.
  * Added clipping support
+ * Added `VertexEffect` interface, instances of which can be set on `SkeletonMesh`. Allows to modify vertices before submitting them to GPU. See `SwirlEffect`, `JitterEffect`.
 
 ### Widget backend
  * Fixed WebGL context loss (see WebGL backend changes). Enabled automatically.

+ 2 - 0
spine-c/spine-c/src/spine/Bone.c

@@ -46,6 +46,8 @@ spBone* spBone_create (spBoneData* data, spSkeleton* skeleton, spBone* parent) {
 	CONST_CAST(spBoneData*, self->data) = data;
 	CONST_CAST(spSkeleton*, self->skeleton) = skeleton;
 	CONST_CAST(spBone*, self->parent) = parent;
+	CONST_CAST(float, self->a) = 1.0f;
+	CONST_CAST(float, self->d) = 1.0f;
 	spBone_setToSetupPose(self);
 	return self;
 }

+ 31 - 15
spine-csharp/src/Animation.cs

@@ -797,6 +797,8 @@ namespace Spine {
 	}
 
 	public class DeformTimeline : CurveTimeline {
+		static float[] zeros = new float[64];
+
 		internal int slotIndex;
 		internal float[] frames;
 		internal float[][] frameVertices;
@@ -825,35 +827,51 @@ namespace Spine {
 
 		override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, MixPose pose, MixDirection direction) {
 			Slot slot = skeleton.slots.Items[slotIndex];
-			VertexAttachment slotAttachment = slot.attachment as VertexAttachment;
-			if (slotAttachment == null || !slotAttachment.ApplyDeform(attachment)) return;
+			VertexAttachment vertexAttachment = slot.attachment as VertexAttachment;
+			if (vertexAttachment == null || !vertexAttachment.ApplyDeform(attachment)) return;
 
 			var verticesArray = slot.attachmentVertices;
 			float[][] frameVertices = this.frameVertices;
 			int vertexCount = frameVertices[0].Length;
-			if (verticesArray.Count != vertexCount && pose != MixPose.Setup) alpha = 1; // Don't mix from uninitialized slot vertices.
-			// verticesArray.SetSize(vertexCount) // Ensure size and preemptively set count.
-			if (verticesArray.Capacity < vertexCount) verticesArray.Capacity = vertexCount;
+			if (verticesArray.Capacity < vertexCount) verticesArray.Capacity = vertexCount;	// verticesArray.SetSize(vertexCount) // Ensure size and preemptively set count.
 			verticesArray.Count = vertexCount;
 			float[] vertices = verticesArray.Items;
 
 			float[] frames = this.frames;
 			if (time < frames[0]) {
+				
 				switch (pose) {
 				case MixPose.Setup:
-					verticesArray.Clear();
+					float[] zeroVertices;
+					if (vertexAttachment.bones == null) {
+						// Unweighted vertex positions (setup pose).
+						zeroVertices = vertexAttachment.vertices;
+					} else {
+						// Weighted deform offsets (zeros).
+						zeroVertices = DeformTimeline.zeros;
+						if (zeroVertices.Length < vertexCount) DeformTimeline.zeros = zeroVertices = new float[vertexCount];
+					}
+					Array.Copy(zeroVertices, 0, vertices, 0, vertexCount);
 					return;
 				case MixPose.Current:
-					alpha = 1 - alpha;
-					for (int i = 0; i < vertexCount; i++)
-						vertices[i] *= alpha;
-
+					if (alpha == 1) return;
+					if (vertexAttachment.bones == null) {
+						// Unweighted vertex positions.
+						float[] setupVertices = vertexAttachment.vertices;
+						for (int i = 0; i < vertexCount; i++)
+							vertices[i] += (setupVertices[i] - vertices[i]) * alpha;
+					} else {
+						// Weighted deform offsets.
+						alpha = 1 - alpha;
+						for (int i = 0; i < vertexCount; i++)
+							vertices[i] *= alpha;
+					}
+					return;
+				default:
 					return;
 				}
-				return;
-			}
-
 
+			}
 
 			if (time >= frames[frames.Length - 1]) { // Time is after last frame.
 				float[] lastVertices = frameVertices[frames.Length - 1];
@@ -861,7 +879,6 @@ namespace Spine {
 					// Vertex positions or deform offsets, no alpha.
 					Array.Copy(lastVertices, 0, vertices, 0, vertexCount);
 				} else if (pose == MixPose.Setup) {
-					VertexAttachment vertexAttachment = slotAttachment;
 					if (vertexAttachment.bones == null) {
 						// Unweighted vertex positions, with alpha.
 						float[] setupVertices = vertexAttachment.vertices;
@@ -896,7 +913,6 @@ namespace Spine {
 					vertices[i] = prev + (nextVertices[i] - prev) * percent;
 				}
 			} else if (pose == MixPose.Setup) {
-				VertexAttachment vertexAttachment = (VertexAttachment)slotAttachment;
 				if (vertexAttachment.bones == null) {
 					// Unweighted vertex positions, with alpha.
 					var setupVertices = vertexAttachment.vertices;

+ 1 - 5
spine-csharp/src/AnimationState.cs

@@ -616,14 +616,10 @@ namespace Spine {
 			propertyIDs.Clear();
 			var mixingTo = this.mixingTo;
 
-			TrackEntry lastEntry = null;
 			var tracksItems = tracks.Items;
 			for (int i = 0, n = tracks.Count; i < n; i++) {
 				var entry = tracksItems[i];
-				if (entry != null) {
-					entry.SetTimelineData(lastEntry, mixingTo, propertyIDs);
-					lastEntry = entry;
-				}
+				if (entry != null) entry.SetTimelineData(null, mixingTo, propertyIDs);
 			}
 		}
 

+ 0 - 1
spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/VertexEffectTest.java

@@ -39,7 +39,6 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
 import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch;
 import com.badlogic.gdx.graphics.g2d.TextureAtlas;
 import com.badlogic.gdx.math.Interpolation;
-import com.esotericsoftware.spine.vertexeffects.JitterEffect;
 import com.esotericsoftware.spine.vertexeffects.SwirlEffect;
 
 public class VertexEffectTest extends ApplicationAdapter {

+ 11 - 16
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java

@@ -930,10 +930,19 @@ public class Animation {
 			float[] frames = this.frames;
 			if (time < frames[0]) { // Time is before first frame.
 				VertexAttachment vertexAttachment = (VertexAttachment)slotAttachment;
-
 				switch (pose) {
 				case setup:
-					break;
+					float[] zeroVertices;
+					if (vertexAttachment.getBones() == null) {
+						// Unweighted vertex positions (setup pose).
+						zeroVertices = vertexAttachment.getVertices();
+					} else {
+						// Weighted deform offsets (zeros).
+						zeroVertices = zeros;
+						if (zeroVertices.length < vertexCount) zeros = zeroVertices = new float[vertexCount];
+					}
+					System.arraycopy(zeroVertices, 0, vertices, 0, vertexCount);
+					return;
 				case current:
 					if (alpha == 1) break;
 					if (vertexAttachment.getBones() == null) {
@@ -947,21 +956,7 @@ public class Animation {
 						for (int i = 0; i < vertexCount; i++)
 							vertices[i] *= alpha;
 					}
-					// Fall thru.
-				default:
-					return;
-				}
-
-				float[] zeroVertices;
-				if (vertexAttachment.getBones() == null) {
-					// Unweighted vertex positions (setup pose).
-					zeroVertices = vertexAttachment.getVertices();
-				} else {
-					// Weighted deform offsets (zeros).
-					zeroVertices = zeros;
-					if (zeroVertices.length < vertexCount) zeros = zeroVertices = new float[vertexCount];
 				}
-				System.arraycopy(zeroVertices, 0, vertices, 0, vertexCount);
 				return;
 			}
 

+ 1 - 5
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java

@@ -610,13 +610,9 @@ public class AnimationState {
 		propertyIDs.clear();
 		Array<TrackEntry> mixingTo = this.mixingTo;
 
-		TrackEntry lastEntry = null;
 		for (int i = 0, n = tracks.size; i < n; i++) {
 			TrackEntry entry = tracks.get(i);
-			if (entry != null) {
-				entry.setTimelineData(lastEntry, mixingTo, propertyIDs);
-				lastEntry = entry;
-			}
+			if (entry != null) entry.setTimelineData(null, mixingTo, propertyIDs);
 		}
 	}
 

+ 1 - 1
spine-ts/build/spine-all.js

@@ -3781,7 +3781,7 @@ var spine;
 							clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
 							if (twoColor) {
 								clippedVerticesItems[s + 8] = dark.r;
-								clippedVerticesItems[s + 8] = dark.g;
+								clippedVerticesItems[s + 9] = dark.g;
 								clippedVerticesItems[s + 10] = dark.b;
 								clippedVerticesItems[s + 11] = dark.a;
 							}

+ 1 - 1
spine-ts/build/spine-canvas.js

@@ -3781,7 +3781,7 @@ var spine;
 							clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
 							if (twoColor) {
 								clippedVerticesItems[s + 8] = dark.r;
-								clippedVerticesItems[s + 8] = dark.g;
+								clippedVerticesItems[s + 9] = dark.g;
 								clippedVerticesItems[s + 10] = dark.b;
 								clippedVerticesItems[s + 11] = dark.a;
 							}

+ 1 - 1
spine-ts/build/spine-core.js

@@ -3781,7 +3781,7 @@ var spine;
 							clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
 							if (twoColor) {
 								clippedVerticesItems[s + 8] = dark.r;
-								clippedVerticesItems[s + 8] = dark.g;
+								clippedVerticesItems[s + 9] = dark.g;
 								clippedVerticesItems[s + 10] = dark.b;
 								clippedVerticesItems[s + 11] = dark.a;
 							}

+ 1 - 1
spine-ts/build/spine-threejs.js

@@ -3781,7 +3781,7 @@ var spine;
 							clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
 							if (twoColor) {
 								clippedVerticesItems[s + 8] = dark.r;
-								clippedVerticesItems[s + 8] = dark.g;
+								clippedVerticesItems[s + 9] = dark.g;
 								clippedVerticesItems[s + 10] = dark.b;
 								clippedVerticesItems[s + 11] = dark.a;
 							}

+ 1 - 1
spine-ts/build/spine-webgl.js

@@ -3781,7 +3781,7 @@ var spine;
 							clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
 							if (twoColor) {
 								clippedVerticesItems[s + 8] = dark.r;
-								clippedVerticesItems[s + 8] = dark.g;
+								clippedVerticesItems[s + 9] = dark.g;
 								clippedVerticesItems[s + 10] = dark.b;
 								clippedVerticesItems[s + 11] = dark.a;
 							}

+ 1 - 1
spine-ts/build/spine-widget.js

@@ -3781,7 +3781,7 @@ var spine;
 							clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
 							if (twoColor) {
 								clippedVerticesItems[s + 8] = dark.r;
-								clippedVerticesItems[s + 8] = dark.g;
+								clippedVerticesItems[s + 9] = dark.g;
 								clippedVerticesItems[s + 10] = dark.b;
 								clippedVerticesItems[s + 11] = dark.a;
 							}

+ 1 - 1
spine-ts/core/src/SkeletonClipping.ts

@@ -130,7 +130,7 @@ module spine {
 							clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
 							if (twoColor) {
 								clippedVerticesItems[s + 8] = dark.r;
-								clippedVerticesItems[s + 8] = dark.g;
+								clippedVerticesItems[s + 9] = dark.g;
 								clippedVerticesItems[s + 10] = dark.b;
 								clippedVerticesItems[s + 11] = dark.a;
 							}

+ 312 - 0
spine-unity/Assets/Examples/Other Examples/VertexEffect.unity

@@ -0,0 +1,312 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!29 &1
+OcclusionCullingSettings:
+  m_ObjectHideFlags: 0
+  serializedVersion: 2
+  m_OcclusionBakeSettings:
+    smallestOccluder: 5
+    smallestHole: 0.25
+    backfaceThreshold: 100
+  m_SceneGUID: 00000000000000000000000000000000
+  m_OcclusionCullingData: {fileID: 0}
+--- !u!104 &2
+RenderSettings:
+  m_ObjectHideFlags: 0
+  serializedVersion: 8
+  m_Fog: 0
+  m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
+  m_FogMode: 3
+  m_FogDensity: 0.01
+  m_LinearFogStart: 0
+  m_LinearFogEnd: 300
+  m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
+  m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
+  m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
+  m_AmbientIntensity: 1
+  m_AmbientMode: 3
+  m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
+  m_SkyboxMaterial: {fileID: 0}
+  m_HaloStrength: 0.5
+  m_FlareStrength: 1
+  m_FlareFadeSpeed: 3
+  m_HaloTexture: {fileID: 0}
+  m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
+  m_DefaultReflectionMode: 0
+  m_DefaultReflectionResolution: 128
+  m_ReflectionBounces: 1
+  m_ReflectionIntensity: 1
+  m_CustomReflection: {fileID: 0}
+  m_Sun: {fileID: 0}
+  m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
+--- !u!157 &3
+LightmapSettings:
+  m_ObjectHideFlags: 0
+  serializedVersion: 9
+  m_GIWorkflowMode: 1
+  m_GISettings:
+    serializedVersion: 2
+    m_BounceScale: 1
+    m_IndirectOutputScale: 1
+    m_AlbedoBoost: 1
+    m_TemporalCoherenceThreshold: 1
+    m_EnvironmentLightingMode: 0
+    m_EnableBakedLightmaps: 0
+    m_EnableRealtimeLightmaps: 0
+  m_LightmapEditorSettings:
+    serializedVersion: 8
+    m_Resolution: 2
+    m_BakeResolution: 40
+    m_TextureWidth: 1024
+    m_TextureHeight: 1024
+    m_AO: 0
+    m_AOMaxDistance: 1
+    m_CompAOExponent: 1
+    m_CompAOExponentDirect: 0
+    m_Padding: 2
+    m_LightmapParameters: {fileID: 0}
+    m_LightmapsBakeMode: 1
+    m_TextureCompression: 1
+    m_FinalGather: 0
+    m_FinalGatherFiltering: 1
+    m_FinalGatherRayCount: 256
+    m_ReflectionCompression: 2
+    m_MixedBakeMode: 3
+    m_BakeBackend: 0
+    m_PVRSampling: 1
+    m_PVRDirectSampleCount: 32
+    m_PVRSampleCount: 500
+    m_PVRBounces: 2
+    m_PVRFiltering: 0
+    m_PVRFilteringMode: 1
+    m_PVRCulling: 1
+    m_PVRFilteringGaussRadiusDirect: 1
+    m_PVRFilteringGaussRadiusIndirect: 5
+    m_PVRFilteringGaussRadiusAO: 2
+    m_PVRFilteringAtrousColorSigma: 1
+    m_PVRFilteringAtrousNormalSigma: 1
+    m_PVRFilteringAtrousPositionSigma: 1
+  m_LightingDataAsset: {fileID: 0}
+  m_ShadowMaskMode: 2
+--- !u!196 &4
+NavMeshSettings:
+  serializedVersion: 2
+  m_ObjectHideFlags: 0
+  m_BuildSettings:
+    serializedVersion: 2
+    agentTypeID: 0
+    agentRadius: 0.5
+    agentHeight: 2
+    agentSlope: 45
+    agentClimb: 0.4
+    ledgeDropHeight: 0
+    maxJumpAcrossDistance: 0
+    minRegionArea: 2
+    manualCellSize: 0
+    cellSize: 0.16666667
+    manualTileSize: 0
+    tileSize: 256
+    accuratePlacement: 0
+  m_NavMeshData: {fileID: 0}
+--- !u!1 &485702170
+GameObject:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  serializedVersion: 5
+  m_Component:
+  - component: {fileID: 485702175}
+  - component: {fileID: 485702174}
+  - component: {fileID: 485702173}
+  - component: {fileID: 485702172}
+  - component: {fileID: 485702171}
+  m_Layer: 0
+  m_Name: Spine GameObject (raptor)
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!114 &485702171
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  m_GameObject: {fileID: 485702170}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 8b9ca76eac8062f42b99bbf78e777ee1, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  jitterMagnitude: 0.2
+--- !u!114 &485702172
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  m_GameObject: {fileID: 485702170}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: d247ba06193faa74d9335f5481b2b56c, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  skeletonDataAsset: {fileID: 11400000, guid: 22c4b5e5a0fd9484d83b1aa705b9a54c, type: 2}
+  initialSkinName: default
+  initialFlipX: 0
+  initialFlipY: 0
+  separatorSlotNames: []
+  zSpacing: 0
+  useClipping: 1
+  immutableTriangles: 0
+  pmaVertexColors: 1
+  clearStateOnDisable: 0
+  tintBlack: 0
+  singleSubmesh: 0
+  addNormals: 0
+  calculateTangents: 0
+  logErrors: 0
+  disableRenderingOnOverride: 1
+  _animationName: walk
+  loop: 1
+  timeScale: 1
+--- !u!23 &485702173
+MeshRenderer:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  m_GameObject: {fileID: 485702170}
+  m_Enabled: 1
+  m_CastShadows: 1
+  m_ReceiveShadows: 1
+  m_MotionVectors: 1
+  m_LightProbeUsage: 1
+  m_ReflectionProbeUsage: 1
+  m_Materials:
+  - {fileID: 2100000, guid: 4e2feebfcaa26a54ab19f1ff3e0eae35, type: 2}
+  m_StaticBatchInfo:
+    firstSubMesh: 0
+    subMeshCount: 0
+  m_StaticBatchRoot: {fileID: 0}
+  m_ProbeAnchor: {fileID: 0}
+  m_LightProbeVolumeOverride: {fileID: 0}
+  m_ScaleInLightmap: 1
+  m_PreserveUVs: 0
+  m_IgnoreNormalsForChartDetection: 0
+  m_ImportantGI: 0
+  m_SelectedEditorRenderState: 3
+  m_MinimumChartSize: 4
+  m_AutoUVMaxDistance: 0.5
+  m_AutoUVMaxAngle: 89
+  m_LightmapParameters: {fileID: 0}
+  m_SortingLayerID: 0
+  m_SortingLayer: 0
+  m_SortingOrder: 0
+--- !u!33 &485702174
+MeshFilter:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  m_GameObject: {fileID: 485702170}
+  m_Mesh: {fileID: 0}
+--- !u!4 &485702175
+Transform:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  m_GameObject: {fileID: 485702170}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: -1.1, y: -5.1, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_Children: []
+  m_Father: {fileID: 0}
+  m_RootOrder: 1
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &1172465384
+GameObject:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  serializedVersion: 5
+  m_Component:
+  - component: {fileID: 1172465389}
+  - component: {fileID: 1172465388}
+  - component: {fileID: 1172465387}
+  - component: {fileID: 1172465386}
+  - component: {fileID: 1172465385}
+  m_Layer: 0
+  m_Name: Main Camera
+  m_TagString: MainCamera
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!81 &1172465385
+AudioListener:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  m_GameObject: {fileID: 1172465384}
+  m_Enabled: 1
+--- !u!124 &1172465386
+Behaviour:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  m_GameObject: {fileID: 1172465384}
+  m_Enabled: 1
+--- !u!92 &1172465387
+Behaviour:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  m_GameObject: {fileID: 1172465384}
+  m_Enabled: 1
+--- !u!20 &1172465388
+Camera:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  m_GameObject: {fileID: 1172465384}
+  m_Enabled: 1
+  serializedVersion: 2
+  m_ClearFlags: 1
+  m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
+  m_NormalizedViewPortRect:
+    serializedVersion: 2
+    x: 0
+    y: 0
+    width: 1
+    height: 1
+  near clip plane: 0.3
+  far clip plane: 1000
+  field of view: 60
+  orthographic: 1
+  orthographic size: 7
+  m_Depth: -1
+  m_CullingMask:
+    serializedVersion: 2
+    m_Bits: 4294967295
+  m_RenderingPath: -1
+  m_TargetTexture: {fileID: 0}
+  m_TargetDisplay: 0
+  m_TargetEye: 3
+  m_HDR: 1
+  m_AllowMSAA: 1
+  m_ForceIntoRT: 0
+  m_OcclusionCulling: 1
+  m_StereoConvergence: 10
+  m_StereoSeparation: 0.022
+  m_StereoMirrorMode: 0
+--- !u!4 &1172465389
+Transform:
+  m_ObjectHideFlags: 0
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 0}
+  m_GameObject: {fileID: 1172465384}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: -10}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_Children: []
+  m_Father: {fileID: 0}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

+ 8 - 0
spine-unity/Assets/Examples/Other Examples/VertexEffect.unity.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d2cf975fd2ba8ae4ba3eebbd9b5f6df4
+timeCreated: 1498101478
+licenseType: Free
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 0
spine-unity/Assets/Examples/Scripts/Sample Components/Sample VertexEffects.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: a1a4a1f889c97e84db5e1ef512f77f3e
+folderAsset: yes
+timeCreated: 1498053541
+licenseType: Free
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 85 - 0
spine-unity/Assets/Examples/Scripts/Sample Components/Sample VertexEffects/JitterEffectExample.cs

@@ -0,0 +1,85 @@
+/******************************************************************************
+ * Spine Runtimes Software License v2.5
+ *
+ * Copyright (c) 2013-2016, Esoteric Software
+ * All rights reserved.
+ *
+ * You are granted a perpetual, non-exclusive, non-sublicensable, and
+ * non-transferable license to use, install, execute, and perform the Spine
+ * Runtimes software and derivative works solely for personal or internal
+ * use. Without the written permission of Esoteric Software (see Section 2 of
+ * the Spine Software License Agreement), you may not (a) modify, translate,
+ * adapt, or develop new applications using the Spine Runtimes or otherwise
+ * create derivative works or improvements of the Spine Runtimes or (b) remove,
+ * delete, alter, or obscure any trademarks or any copyright, trademark, patent,
+ * or other intellectual property or proprietary rights notices on or in the
+ * Software, including any copy thereof. Redistributions in binary or source
+ * form must include this license and terms.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
+ * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Spine.Unity.Examples {
+
+	// This is a sample component for C# vertex effects for Spine rendering components.
+	// Using shaders and materials to control vertex properties is still more performant
+	// than using this API, but in cases where your vertex effect logic cannot be
+	// expressed as shader code, these vertex effects can be useful.
+	public class JitterEffectExample : MonoBehaviour {
+
+		[Range(0f, 0.8f)]
+		public float jitterMagnitude = 0.2f;
+
+		SkeletonRenderer skeletonRenderer;
+
+		void OnEnable () {
+			skeletonRenderer = GetComponent<SkeletonRenderer>();
+			if (skeletonRenderer == null) return;
+
+			// Use the OnPostProcessVertices callback to modify the vertices at the correct time.
+			skeletonRenderer.OnPostProcessVertices -= ProcessVertices;
+			skeletonRenderer.OnPostProcessVertices += ProcessVertices;
+
+			Debug.Log("Jitter Effect Enabled.");
+		}
+
+		void ProcessVertices (MeshGeneratorBuffers buffers) {
+			if (!this.enabled) return;
+
+			// For efficiency, limit your effect to the actual mesh vertex count using vertexCount
+			int vertexCount = buffers.vertexCount;
+
+			// Modify vertex positions by accessing Vector3[] vertexBuffer
+			var vertices = buffers.vertexBuffer;
+			for (int i = 0; i < vertexCount; i++)
+				vertices[i] += (Vector3)(Random.insideUnitCircle * jitterMagnitude);
+
+			// You can also modify uvs and colors.
+			//var uvs = buffers.uvBuffer;
+			//var colors = buffers.colorBuffer;
+
+			// 
+		}
+
+		void OnDisable () {
+			if (skeletonRenderer == null) return;
+			skeletonRenderer.OnPostProcessVertices -= ProcessVertices;
+
+			Debug.Log("Jitter Effect Disabled.");
+		}
+	}
+
+}

+ 12 - 0
spine-unity/Assets/Examples/Scripts/Sample Components/Sample VertexEffects/JitterEffectExample.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 8b9ca76eac8062f42b99bbf78e777ee1
+timeCreated: 1498053868
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 48 - 35
spine-unity/Assets/spine-unity/Asset Types/Editor/SkeletonDataAssetInspector.cs

@@ -74,7 +74,8 @@ namespace Spine.Unity.Editor {
 			SpineEditorUtilities.ConfirmInitialization();
 			m_skeletonDataAsset = (SkeletonDataAsset)target;
 
-			atlasAssets = serializedObject.FindProperty("atlasAssets");
+			bool newAtlasAssets = atlasAssets == null;
+			if (newAtlasAssets) atlasAssets = serializedObject.FindProperty("atlasAssets");
 			skeletonJSON = serializedObject.FindProperty("skeletonJSON");
 			scale = serializedObject.FindProperty("scale");
 			fromAnimation = serializedObject.FindProperty("fromAnimation");
@@ -87,10 +88,10 @@ namespace Spine.Unity.Editor {
 			#endif
 
 			#if SPINE_TK2D
-			atlasAssets.isExpanded = false;
+			if (newAtlasAssets) atlasAssets.isExpanded = false;
 			spriteCollection = serializedObject.FindProperty("spriteCollection");
 			#else
-			atlasAssets.isExpanded = true;
+			if (newAtlasAssets) atlasAssets.isExpanded = true;
 			#endif
 
 			m_skeletonDataAssetGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_skeletonDataAsset));
@@ -470,44 +471,56 @@ namespace Spine.Unity.Editor {
 				if (SpineEditorUtilities.IsSpineData((TextAsset)skeletonJSON.objectReferenceValue) == false) {
 					warnings.Add("Skeleton data file is not a valid JSON or binary file.");
 				} else {
-					#if !SPINE_TK2D
-					bool detectedNullAtlasEntry = false;
-					var atlasList = new List<Atlas>();
-					var actualAtlasAssets = m_skeletonDataAsset.atlasAssets;
-					for (int i = 0; i < actualAtlasAssets.Length; i++) {
-						if (m_skeletonDataAsset.atlasAssets[i] == null) {
-							detectedNullAtlasEntry = true;
-							break;
-						} else {
-							atlasList.Add(actualAtlasAssets[i].GetAtlas());
+					#if SPINE_TK2D
+					bool searchForSpineAtlasAssets = true;
+					bool isSpriteCollectionNull = spriteCollection.objectReferenceValue == null;
+					if (!isSpriteCollectionNull) searchForSpineAtlasAssets = false;
+					//else
+					//	warnings.Add("Your sprite collection may have missing images.");
+					#else
+					const bool searchForSpineAtlasAssets = true;
+					#endif
+
+					if (searchForSpineAtlasAssets) {
+						bool detectedNullAtlasEntry = false;
+						var atlasList = new List<Atlas>();
+						var actualAtlasAssets = m_skeletonDataAsset.atlasAssets;
+
+						for (int i = 0; i < actualAtlasAssets.Length; i++) {
+							if (m_skeletonDataAsset.atlasAssets[i] == null) {
+								detectedNullAtlasEntry = true;
+								break;
+							} else {
+								atlasList.Add(actualAtlasAssets[i].GetAtlas());
+							}
 						}
-					}
 
-					if (detectedNullAtlasEntry)
-						warnings.Add("AtlasAsset elements should not be null.");
-					else {
-						// Get requirements.
-						var missingPaths = SpineEditorUtilities.GetRequiredAtlasRegions(AssetDatabase.GetAssetPath((TextAsset)skeletonJSON.objectReferenceValue));
-
-						foreach (var atlas in atlasList) {
-							for (int i = 0; i < missingPaths.Count; i++) {
-								if (atlas.FindRegion(missingPaths[i]) != null) {
-									missingPaths.RemoveAt(i);
-									i--;
+						if (detectedNullAtlasEntry) {
+							warnings.Add("AtlasAsset elements should not be null.");
+						} else {
+							// Get requirements.
+							var missingPaths = SpineEditorUtilities.GetRequiredAtlasRegions(AssetDatabase.GetAssetPath((TextAsset)skeletonJSON.objectReferenceValue));
+
+							foreach (var atlas in atlasList) {
+								for (int i = 0; i < missingPaths.Count; i++) {
+									if (atlas.FindRegion(missingPaths[i]) != null) {
+										missingPaths.RemoveAt(i);
+										i--;
+									}
 								}
 							}
-						}
 
-						foreach (var str in missingPaths)
-							warnings.Add("Missing Region: '" + str + "'");
-						
+							#if SPINE_TK2D
+							if (missingPaths.Count > 0)
+								warnings.Add("Missing regions. SkeletonDataAsset requires tk2DSpriteCollectionData or Spine AtlasAssets.");
+							#endif
+
+							foreach (var str in missingPaths)
+								warnings.Add("Missing Region: '" + str + "'");
+
+						}
 					}
-					#else
-					if (spriteCollection.objectReferenceValue == null)
-						warnings.Add("SkeletonDataAsset requires tk2DSpriteCollectionData.");
-//					else
-//						warnings.Add("Your sprite collection may have missing images.");
-					#endif
+
 				}
 			}
 		}

+ 18 - 6
spine-unity/Assets/spine-unity/BoneFollower.cs

@@ -47,9 +47,9 @@ namespace Spine.Unity {
 			}
 		}
 
-		/// <summary>If a bone isn't set in code, boneName is used to find the bone.</summary>
+		/// <summary>If a bone isn't set in code, boneName is used to find the bone at the beginning. For runtime switching by name, use SetBoneByName. You can also set the BoneFollower.bone field directly.</summary>
 		[SpineBone(dataField: "skeletonRenderer")]
-		public String boneName;
+		[SerializeField] public string boneName;
 
 		public bool followZPosition = true;
 		public bool followBoneRotation = true;
@@ -65,10 +65,25 @@ namespace Spine.Unity {
 		#endregion
 
 		[NonSerialized] public bool valid;
+		/// <summary>
+		/// The bone.
+		/// </summary>
 		[NonSerialized] public Bone bone;
 		Transform skeletonTransform;
 		bool skeletonTransformIsParent;
 
+		/// <summary>
+		/// Sets the target bone by its bone name. Returns false if no bone was found.</summary>
+		public bool SetBone (string name) {
+			bone = skeletonRenderer.skeleton.FindBone(name);
+			if (bone == null) {
+				Debug.LogError("Bone not found: " + name, this);
+				return false;
+			}
+			boneName = name;
+			return true;
+		}
+
 		public void Awake () {
 			if (initializeOnAwake) Initialize();
 		}
@@ -115,10 +130,7 @@ namespace Spine.Unity {
 			if (bone == null) {
 				if (string.IsNullOrEmpty(boneName)) return;
 				bone = skeletonRenderer.skeleton.FindBone(boneName);
-				if (bone == null) {
-					Debug.LogError("Bone not found: " + boneName, this);
-					return;
-				}
+				if (!SetBone(boneName)) return;
 			}
 
 			Transform thisTransform = this.transform;

+ 1 - 1
spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs

@@ -95,7 +95,7 @@ namespace Spine.Unity.Editor {
 			var transform = skeletonRendererComponent.transform;
 			var skeleton = skeletonRendererComponent.skeleton;
 
-			if (string.IsNullOrEmpty(tbf.boneName)) {
+			if (string.IsNullOrEmpty(boneName.stringValue)) {
 				SpineHandles.DrawBones(transform, skeleton);
 				SpineHandles.DrawBoneNames(transform, skeleton);
 				Handles.Label(tbf.transform.position, "No bone selected", EditorStyles.helpBox);

+ 31 - 6
spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs

@@ -73,7 +73,24 @@ namespace Spine.Unity {
 		public int SlotCount { get { return endSlot - startSlot; } }
 	}
 
-	public delegate void MeshGeneratorDelegate (MeshGenerator meshGenerator);
+	public delegate void MeshGeneratorDelegate (MeshGeneratorBuffers buffers);
+
+	public struct MeshGeneratorBuffers {
+		/// <summary>The vertex count that will actually be used for the mesh. The Lengths of the buffer arrays may be larger than this number.</summary>
+		public int vertexCount;
+
+		/// <summary> Vertex positions. To be used for UnityEngine.Mesh.vertices.</summary>
+		public Vector3[] vertexBuffer;
+
+		/// <summary> Vertex UVs. To be used for UnityEngine.Mesh.uvs.</summary>
+		public Vector2[] uvBuffer;
+
+		/// <summary> Vertex colors. To be used for UnityEngine.Mesh.colors32.</summary>
+		public Color32[] colorBuffer;
+
+		/// <summary> The Spine rendering component's MeshGenerator. </summary>
+		public MeshGenerator meshGenerator;
+	}
 
 	[System.Serializable]
 	public class MeshGenerator {
@@ -117,10 +134,6 @@ namespace Spine.Unity {
 		[NonSerialized] readonly ExposedList<Color32> colorBuffer = new ExposedList<Color32>(4);
 		[NonSerialized] readonly ExposedList<ExposedList<int>> submeshes = new ExposedList<ExposedList<int>> { new ExposedList<int>(6) }; // start with 1 submesh.
 
-		public Vector3[] VertexBuffer { get { return this.vertexBuffer.Items; } }
-		public Vector2[] UVBuffer { get { return this.uvBuffer.Items; } }
-		public Color32[] ColorBuffer { get { return this.colorBuffer.Items; } }
-
 		[NonSerialized] Vector2 meshBoundsMin, meshBoundsMax;
 		[NonSerialized] float meshBoundsThickness;
 		[NonSerialized] int submeshIndex = 0;
@@ -139,6 +152,18 @@ namespace Spine.Unity {
 
 		public int VertexCount { get { return vertexBuffer.Count; } }
 
+		public MeshGeneratorBuffers Buffers {
+			get {
+				return new MeshGeneratorBuffers {
+					vertexCount = this.VertexCount,
+					vertexBuffer = this.vertexBuffer.Items,
+					uvBuffer = this.uvBuffer.Items,
+					colorBuffer = this.colorBuffer.Items,
+					meshGenerator = this
+				};
+			}
+		}
+
 		#region Step 1 : Generate Instructions
 		public static void GenerateSingleSubmeshInstruction (SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Material material) {
 			ExposedList<Slot> drawOrder = skeleton.drawOrder;
@@ -332,7 +357,7 @@ namespace Spine.Unity {
 						material = (Material)((AtlasRegion)rendererObject).page.rendererObject;
 					}
 					#else
-					Material material = (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject;
+					Material material = (rendererObject is Material) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject;
 					#endif
 
 					if (current.forceSeparate || (current.rawVertexCount > 0 && !System.Object.ReferenceEquals(current.material, material))) { // Material changed. Add the previous submesh.

+ 1 - 1
spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/Editor/BoundingBoxFollowerInspector.cs

@@ -156,7 +156,7 @@ namespace Spine.Unity.Editor {
 			if (Event.current.type == EventType.Repaint) {
 				if (addBoneFollower) {
 					var boneFollower = follower.gameObject.AddComponent<BoneFollower>();
-					boneFollower.boneName = follower.Slot.Data.BoneData.Name;
+					boneFollower.SetBone(follower.Slot.Data.BoneData.Name);
 					addBoneFollower = false;
 				}
 

+ 10 - 3
spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs

@@ -122,11 +122,18 @@ namespace Spine.Unity {
 
 		#region Internals
 		// This is used by the UI system to determine what to put in the MaterialPropertyBlock.
-		public Texture OverrideTexture { get; set; }
+		Texture overrideTexture;
+		public Texture OverrideTexture {
+			get { return overrideTexture; }
+			set {
+				canvasRenderer.SetTexture(value);
+				overrideTexture = value;
+			}
+		}
 		public override Texture mainTexture {
 			get { 
 				// Fail loudly when incorrectly set up.
-				if (OverrideTexture != null) return OverrideTexture;
+				if (overrideTexture != null) return overrideTexture;
 				return skeletonDataAsset == null ? null : skeletonDataAsset.atlasAssets[0].materials[0].mainTexture;
 			}
 		}
@@ -272,7 +279,7 @@ namespace Spine.Unity {
 			}
 
 			if (canvas != null) meshGenerator.ScaleVertexData(canvas.referencePixelsPerUnit);
-			if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator);
+			if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator.Buffers);
 
 			var mesh = smartMesh.mesh;
 			meshGenerator.FillVertexData(mesh);

+ 9 - 1
spine-unity/Assets/spine-unity/Modules/TK2D/SpriteCollectionAttachmentLoader.cs

@@ -33,7 +33,7 @@ using System;
 using UnityEngine;
 using Spine;
 
-// TODO: handle TPackerCW flip mode (probably not swap uv horizontaly)
+// MITCH: handle TPackerCW flip mode (probably not swap uv horizontaly)
 namespace Spine.Unity.TK2D {
 	public class SpriteCollectionAttachmentLoader : AttachmentLoader {
 		private tk2dSpriteCollectionData sprites;
@@ -144,6 +144,14 @@ namespace Spine.Unity.TK2D {
 		public PathAttachment NewPathAttachment (Skin skin, string name) {
 			return new PathAttachment(name);
 		}
+
+		public PointAttachment NewPointAttachment (Skin skin, string name) {
+			return new PointAttachment(name);
+		}
+
+		public ClippingAttachment NewClippingAttachment (Skin skin, string name) {
+			return new ClippingAttachment(name);
+		}
 	}
 }
 #endif

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

@@ -283,7 +283,7 @@ namespace Spine.Unity {
 					meshGenerator.BuildMeshWithArrays(currentInstructions, updateTriangles);
 			}
 
-			if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator);
+			if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator.Buffers);
 
 			// STEP 3. Move the mesh data into a UnityEngine.Mesh ===========================================================================
 			var currentMesh = currentSmartMesh.mesh;