mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-05 14:54:53 +08:00
Merge branch '3.6' into 3.7-beta
This commit is contained in:
commit
2c88c121d6
@ -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,43 +827,58 @@ 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];
|
||||
if (alpha == 1) {
|
||||
// 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;
|
||||
|
||||
312
spine-unity/Assets/Examples/Other Examples/VertexEffect.unity
Normal file
312
spine-unity/Assets/Examples/Other Examples/VertexEffect.unity
Normal file
@ -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}
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2cf975fd2ba8ae4ba3eebbd9b5f6df4
|
||||
timeCreated: 1498101478
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1a4a1f889c97e84db5e1ef512f77f3e
|
||||
folderAsset: yes
|
||||
timeCreated: 1498053541
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b9ca76eac8062f42b99bbf78e777ee1
|
||||
timeCreated: 1498053868
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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 SetBoneByName (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 (!SetBoneByName(boneName)) return;
|
||||
}
|
||||
|
||||
Transform thisTransform = this.transform;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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.SetBoneByName(follower.Slot.Data.BoneData.Name);
|
||||
addBoneFollower = false;
|
||||
}
|
||||
|
||||
|
||||
@ -272,7 +272,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);
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user