mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 08:38:43 +08:00
[csharp][unity] Adjusted spine-csharp and dependent modules to being used as separate UPM packages. See #1676.
This commit is contained in:
parent
2d34b84f46
commit
91f7969cdc
@ -546,6 +546,26 @@ namespace Spine {
|
||||
}
|
||||
|
||||
float x, y;
|
||||
EvaluateCurve(out x, out y, time); // note: reference implementation has code inlined
|
||||
|
||||
switch (blend) {
|
||||
case MixBlend.Setup:
|
||||
bone.x = bone.data.x + x * alpha;
|
||||
bone.y = bone.data.y + y * alpha;
|
||||
break;
|
||||
case MixBlend.First:
|
||||
case MixBlend.Replace:
|
||||
bone.x += (bone.data.x + x - bone.x) * alpha;
|
||||
bone.y += (bone.data.y + y - bone.y) * alpha;
|
||||
break;
|
||||
case MixBlend.Add:
|
||||
bone.x += x * alpha;
|
||||
bone.y += y * alpha;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void EvaluateCurve (out float x, out float y, float time) {
|
||||
int i = Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES];
|
||||
switch (curveType) {
|
||||
case LINEAR:
|
||||
@ -565,21 +585,26 @@ namespace Spine {
|
||||
y = GetBezierValue(time, i, VALUE2, curveType + BEZIER_SIZE - BEZIER);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (blend) {
|
||||
case MixBlend.Setup:
|
||||
bone.x = bone.data.x + x * alpha;
|
||||
bone.y = bone.data.y + y * alpha;
|
||||
break;
|
||||
case MixBlend.First:
|
||||
case MixBlend.Replace:
|
||||
bone.x += (bone.data.x + x - bone.x) * alpha;
|
||||
bone.y += (bone.data.y + y - bone.y) * alpha;
|
||||
break;
|
||||
case MixBlend.Add:
|
||||
bone.x += x * alpha;
|
||||
bone.y += y * alpha;
|
||||
break;
|
||||
/// <summary>Evaluates the resulting value of a TranslateTimeline at a given time.
|
||||
/// If no SkeletonData is given, values are returned as difference to setup pose
|
||||
/// instead of absolute values.</summary>
|
||||
public void Evaluate (out float outX, out float outY, float time, SkeletonData skeletonData) {
|
||||
outX = outY = 0;
|
||||
if (time < frames[0]) return;
|
||||
|
||||
float x, y;
|
||||
EvaluateCurve(out x, out y, time);
|
||||
|
||||
if (skeletonData == null) {
|
||||
outX = x;
|
||||
outY = y;
|
||||
return;
|
||||
} else {
|
||||
var boneData = skeletonData.bones.Items[boneIndex];
|
||||
outX = x + boneData.x;
|
||||
outY = y + boneData.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1139,6 +1139,8 @@ namespace Spine {
|
||||
/// </summary>
|
||||
public float Alpha { get { return alpha; } set { alpha = value; } }
|
||||
|
||||
public float InterruptAlpha { get { return interruptAlpha; } }
|
||||
|
||||
/// <summary>
|
||||
/// When the mix percentage (<see cref="TrackEntry.MixTime"/> / <see cref="TrackEntry.MixDuration"/>) is less than the
|
||||
/// <code>EventThreshold</code>, event timelines are applied while this animation is being mixed out. Defaults to 0, so event
|
||||
@ -1257,6 +1259,14 @@ namespace Spine {
|
||||
override public string ToString () {
|
||||
return animation == null ? "<none>" : animation.name;
|
||||
}
|
||||
|
||||
// Note: This method is required by SpineAnimationStateMixerBehaviour,
|
||||
// which is part of the timeline extension package. Thus the internal member variable
|
||||
// nextTrackLast is not accessible. We favor providing this method
|
||||
// over exposing nextTrackLast as public property, which would rather confuse users.
|
||||
public void AllowImmediateQueue () {
|
||||
if (nextTrackLast < 0) nextTrackLast = 0;
|
||||
}
|
||||
}
|
||||
|
||||
class EventQueue {
|
||||
|
||||
34
spine-csharp/src/package.json
Normal file
34
spine-csharp/src/package.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "com.esotericsoftware.spine.spine-csharp",
|
||||
"displayName": "spine-csharp Runtime",
|
||||
"description": "This plugin provides the spine-csharp core runtime.",
|
||||
"version": "4.0.0",
|
||||
"unity": "2018.3",
|
||||
"author": {
|
||||
"name": "Esoteric Software",
|
||||
"email": "contact@esotericsoftware.com",
|
||||
"url": "http://esotericsoftware.com/"
|
||||
},
|
||||
"dependencies": {
|
||||
},
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:EsotericSoftware/spine-runtimes.git"
|
||||
},
|
||||
"keywords": [
|
||||
"spine",
|
||||
"spine-csharp",
|
||||
"runtimes",
|
||||
"2d",
|
||||
"skeletal",
|
||||
"animation"
|
||||
],
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"bugs": {
|
||||
"url": "https://github.com/EsotericSoftware/spine-runtimes/issues"
|
||||
},
|
||||
"homepage": "https://github.com/EsotericSoftware/spine-runtimes#readme"
|
||||
}
|
||||
7
spine-csharp/src/package.json.meta
Normal file
7
spine-csharp/src/package.json.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84ca0094807afe74295fdf4864a0ceca
|
||||
PackageManifestImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
4
spine-csharp/src/spine-csharp.asmdef
Normal file
4
spine-csharp/src/spine-csharp.asmdef
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "spine-csharp",
|
||||
"references": []
|
||||
}
|
||||
7
spine-csharp/src/spine-csharp.asmdef.meta
Normal file
7
spine-csharp/src/spine-csharp.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72d1fea872bd7a449bf3818f2b0a6708
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,20 +1,33 @@
|
||||
{
|
||||
"name": "com.esotericsoftware.spine.spine-unity-examples",
|
||||
"displayName": "spine-unity Runtime Examples",
|
||||
"description": "This plugin provides example scenes and scripts for the spine-unity runtime.",
|
||||
"version": "3.9.0",
|
||||
"unity": "2018.3",
|
||||
"author": {
|
||||
"name": "Esoteric Software",
|
||||
"email": "contact@esotericsoftware.com",
|
||||
"url": "http://esotericsoftware.com/"
|
||||
},
|
||||
"dependencies": {
|
||||
"com.esotericsoftware.spine.spine-unity": "3.9.0"
|
||||
},
|
||||
"keywords": [
|
||||
"spine",
|
||||
"spine-unity",
|
||||
"core"
|
||||
]
|
||||
}
|
||||
"name": "com.esotericsoftware.spine.spine-unity-examples",
|
||||
"displayName": "spine-unity Runtime Examples",
|
||||
"description": "This plugin provides example scenes and scripts for the spine-unity runtime.",
|
||||
"version": "4.0.0",
|
||||
"unity": "2018.3",
|
||||
"author": {
|
||||
"name": "Esoteric Software",
|
||||
"email": "contact@esotericsoftware.com",
|
||||
"url": "http://esotericsoftware.com/"
|
||||
},
|
||||
"dependencies": {
|
||||
"com.esotericsoftware.spine.spine-unity": "4.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:EsotericSoftware/spine-runtimes.git"
|
||||
},
|
||||
"keywords": [
|
||||
"spine",
|
||||
"spine-unity",
|
||||
"runtimes",
|
||||
"2d",
|
||||
"skeletal",
|
||||
"animation"
|
||||
],
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"bugs": {
|
||||
"url": "https://github.com/EsotericSoftware/spine-runtimes/issues"
|
||||
},
|
||||
"homepage": "https://github.com/EsotericSoftware/spine-runtimes#readme",
|
||||
"type": "sample"
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"name": "spine-unity-examples",
|
||||
"references": [ "spine-unity" ]
|
||||
"references": [ "spine-unity", "spine-csharp" ]
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "spine-unity-editor",
|
||||
"references": [
|
||||
"spine-csharp",
|
||||
"spine-unity"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"name": "spine-unity",
|
||||
"references": []
|
||||
"references": [ "spine-csharp" ]
|
||||
}
|
||||
|
||||
@ -76,8 +76,8 @@ namespace Spine.Unity {
|
||||
var slotsItems = skeletonData.Slots.Items;
|
||||
for (int slotIndex = 0, slotCount = skeletonData.Slots.Count; slotIndex < slotCount; slotIndex++) {
|
||||
var slot = slotsItems[slotIndex];
|
||||
if (slot.blendMode == BlendMode.Normal) continue;
|
||||
if (!applyAdditiveMaterial && slot.blendMode == BlendMode.Additive) continue;
|
||||
if (slot.BlendMode == BlendMode.Normal) continue;
|
||||
if (!applyAdditiveMaterial && slot.BlendMode == BlendMode.Additive) continue;
|
||||
|
||||
skinEntries.Clear();
|
||||
foreach (var skin in skeletonData.Skins)
|
||||
@ -102,11 +102,11 @@ namespace Spine.Unity {
|
||||
var slotsItems = skeletonData.Slots.Items;
|
||||
for (int slotIndex = 0, slotCount = skeletonData.Slots.Count; slotIndex < slotCount; slotIndex++) {
|
||||
var slot = slotsItems[slotIndex];
|
||||
if (slot.blendMode == BlendMode.Normal) continue;
|
||||
if (!applyAdditiveMaterial && slot.blendMode == BlendMode.Additive) continue;
|
||||
if (slot.BlendMode == BlendMode.Normal) continue;
|
||||
if (!applyAdditiveMaterial && slot.BlendMode == BlendMode.Additive) continue;
|
||||
|
||||
List<ReplacementMaterial> replacementMaterials = null;
|
||||
switch (slot.blendMode) {
|
||||
switch (slot.BlendMode) {
|
||||
case BlendMode.Multiply:
|
||||
replacementMaterials = multiplyMaterials;
|
||||
break;
|
||||
|
||||
@ -219,7 +219,7 @@ namespace Spine.Unity {
|
||||
|
||||
public void FillStateData () {
|
||||
if (stateData != null) {
|
||||
stateData.defaultMix = defaultMix;
|
||||
stateData.DefaultMix = defaultMix;
|
||||
|
||||
for (int i = 0, n = fromAnimation.Length; i < n; i++) {
|
||||
if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0)
|
||||
|
||||
@ -156,12 +156,12 @@ namespace Spine.Unity {
|
||||
float additionalFlipScale = 1;
|
||||
if (skeletonTransformIsParent) {
|
||||
// Recommended setup: Use local transform properties if Spine GameObject is the immediate parent
|
||||
thisTransform.localPosition = new Vector3(followXYPosition ? bone.worldX : thisTransform.localPosition.x,
|
||||
followXYPosition ? bone.worldY : thisTransform.localPosition.y,
|
||||
thisTransform.localPosition = new Vector3(followXYPosition ? bone.WorldX : thisTransform.localPosition.x,
|
||||
followXYPosition ? bone.WorldY : thisTransform.localPosition.y,
|
||||
followZPosition ? 0f : thisTransform.localPosition.z);
|
||||
if (followBoneRotation) {
|
||||
float halfRotation = Mathf.Atan2(bone.c, bone.a) * 0.5f;
|
||||
if (followLocalScale && bone.scaleX < 0) // Negate rotation from negative scaleX. Don't use negative determinant. local scaleY doesn't factor into used rotation.
|
||||
float halfRotation = Mathf.Atan2(bone.C, bone.A) * 0.5f;
|
||||
if (followLocalScale && bone.ScaleX < 0) // Negate rotation from negative scaleX. Don't use negative determinant. local scaleY doesn't factor into used rotation.
|
||||
halfRotation += Mathf.PI * 0.5f;
|
||||
|
||||
var q = default(Quaternion);
|
||||
@ -171,7 +171,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
} else {
|
||||
// For special cases: Use transform world properties if transform relationship is complicated
|
||||
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.worldX, bone.worldY, 0f));
|
||||
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.WorldX, bone.WorldY, 0f));
|
||||
if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;
|
||||
if (!followXYPosition) {
|
||||
targetWorldPosition.x = thisTransform.position.x;
|
||||
@ -196,7 +196,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
Vector3 worldRotation = skeletonTransform.rotation.eulerAngles;
|
||||
if (followLocalScale && bone.scaleX < 0) boneWorldRotation += 180f;
|
||||
if (followLocalScale && bone.ScaleX < 0) boneWorldRotation += 180f;
|
||||
thisTransform.SetPositionAndRotation(targetWorldPosition, Quaternion.Euler(worldRotation.x, worldRotation.y, worldRotation.z + boneWorldRotation));
|
||||
} else {
|
||||
thisTransform.position = targetWorldPosition;
|
||||
@ -206,9 +206,9 @@ namespace Spine.Unity {
|
||||
* skeletonLossyScale.y * parentLossyScale.y);
|
||||
}
|
||||
|
||||
Vector3 localScale = followLocalScale ? new Vector3(bone.scaleX, bone.scaleY, 1f) : new Vector3(1f, 1f, 1f);
|
||||
Vector3 localScale = followLocalScale ? new Vector3(bone.ScaleX, bone.ScaleY, 1f) : new Vector3(1f, 1f, 1f);
|
||||
if (followSkeletonFlip)
|
||||
localScale.y *= Mathf.Sign(bone.skeleton.ScaleX * bone.skeleton.ScaleY) * additionalFlipScale;
|
||||
localScale.y *= Mathf.Sign(bone.Skeleton.ScaleX * bone.Skeleton.ScaleY) * additionalFlipScale;
|
||||
|
||||
thisTransform.localScale = localScale;
|
||||
}
|
||||
|
||||
@ -144,13 +144,13 @@ namespace Spine.Unity {
|
||||
float additionalFlipScale = 1;
|
||||
if (skeletonTransformIsParent) {
|
||||
// Recommended setup: Use local transform properties if Spine GameObject is the immediate parent
|
||||
thisTransform.localPosition = new Vector3(followXYPosition ? bone.worldX * scale : thisTransform.localPosition.x,
|
||||
followXYPosition ? bone.worldY * scale : thisTransform.localPosition.y,
|
||||
thisTransform.localPosition = new Vector3(followXYPosition ? bone.WorldX * scale : thisTransform.localPosition.x,
|
||||
followXYPosition ? bone.WorldY * scale : thisTransform.localPosition.y,
|
||||
followZPosition ? 0f : thisTransform.localPosition.z);
|
||||
if (followBoneRotation) thisTransform.localRotation = bone.GetQuaternion();
|
||||
} else {
|
||||
// For special cases: Use transform world properties if transform relationship is complicated
|
||||
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.worldX * scale, bone.worldY * scale, 0f));
|
||||
Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.WorldX * scale, bone.WorldY * scale, 0f));
|
||||
if (!followZPosition) targetWorldPosition.z = thisTransform.position.z;
|
||||
if (!followXYPosition) {
|
||||
targetWorldPosition.x = thisTransform.position.x;
|
||||
@ -175,7 +175,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
Vector3 worldRotation = skeletonTransform.rotation.eulerAngles;
|
||||
if (followLocalScale && bone.scaleX < 0) boneWorldRotation += 180f;
|
||||
if (followLocalScale && bone.ScaleX < 0) boneWorldRotation += 180f;
|
||||
thisTransform.SetPositionAndRotation(targetWorldPosition, Quaternion.Euler(worldRotation.x, worldRotation.y, worldRotation.z + boneWorldRotation));
|
||||
} else {
|
||||
thisTransform.position = targetWorldPosition;
|
||||
@ -185,9 +185,9 @@ namespace Spine.Unity {
|
||||
* skeletonLossyScale.y * parentLossyScale.y);
|
||||
}
|
||||
|
||||
Vector3 localScale = followLocalScale ? new Vector3(bone.scaleX, bone.scaleY, 1f) : new Vector3(1f, 1f, 1f);
|
||||
Vector3 localScale = followLocalScale ? new Vector3(bone.ScaleX, bone.ScaleY, 1f) : new Vector3(1f, 1f, 1f);
|
||||
if (followSkeletonFlip)
|
||||
localScale.y *= Mathf.Sign(bone.skeleton.ScaleX * bone.skeleton.ScaleY) * additionalFlipScale;
|
||||
localScale.y *= Mathf.Sign(bone.Skeleton.ScaleX * bone.Skeleton.ScaleY) * additionalFlipScale;
|
||||
thisTransform.localScale = localScale;
|
||||
}
|
||||
|
||||
|
||||
@ -97,13 +97,10 @@ namespace Spine.Unity {
|
||||
return;
|
||||
|
||||
// Don't reinitialize if the setup did not change.
|
||||
if (!overwrite
|
||||
&&
|
||||
colliderTable.Count > 0 && slot != null // Slot is set and colliders already populated.
|
||||
&&
|
||||
skeletonRenderer.skeleton == slot.Skeleton // Skeleton object did not change.
|
||||
&&
|
||||
slotName == slot.data.name // Slot object did not change.
|
||||
if (!overwrite &&
|
||||
colliderTable.Count > 0 && slot != null && // Slot is set and colliders already populated.
|
||||
skeletonRenderer.skeleton == slot.Skeleton && // Skeleton object did not change.
|
||||
slotName == slot.Data.Name // Slot object did not change.
|
||||
)
|
||||
return;
|
||||
|
||||
@ -131,8 +128,8 @@ namespace Spine.Unity {
|
||||
foreach (var skin in skeleton.Data.Skins)
|
||||
AddCollidersForSkin(skin, slotIndex, colliders, ref requiredCollidersCount);
|
||||
|
||||
if (skeleton.skin != null)
|
||||
AddCollidersForSkin(skeleton.skin, slotIndex, colliders, ref requiredCollidersCount);
|
||||
if (skeleton.Skin != null)
|
||||
AddCollidersForSkin(skeleton.Skin, slotIndex, colliders, ref requiredCollidersCount);
|
||||
}
|
||||
DisposeExcessCollidersAfter(requiredCollidersCount);
|
||||
|
||||
|
||||
@ -97,13 +97,10 @@ namespace Spine.Unity {
|
||||
return;
|
||||
|
||||
// Don't reinitialize if the setup did not change.
|
||||
if (!overwrite
|
||||
&&
|
||||
colliderTable.Count > 0 && slot != null // Slot is set and colliders already populated.
|
||||
&&
|
||||
skeletonGraphic.Skeleton == slot.Skeleton // Skeleton object did not change.
|
||||
&&
|
||||
slotName == slot.data.name // Slot object did not change.
|
||||
if (!overwrite &&
|
||||
colliderTable.Count > 0 && slot != null && // Slot is set and colliders already populated.
|
||||
skeletonGraphic.Skeleton == slot.Skeleton && // Skeleton object did not change.
|
||||
slotName == slot.Data.Name // Slot object did not change.
|
||||
)
|
||||
return;
|
||||
|
||||
@ -135,8 +132,8 @@ namespace Spine.Unity {
|
||||
foreach (var skin in skeleton.Data.Skins)
|
||||
AddCollidersForSkin(skin, slotIndex, colliders, scale, ref requiredCollidersCount);
|
||||
|
||||
if (skeleton.skin != null)
|
||||
AddCollidersForSkin(skeleton.skin, slotIndex, colliders, scale, ref requiredCollidersCount);
|
||||
if (skeleton.Skin != null)
|
||||
AddCollidersForSkin(skeleton.Skin, slotIndex, colliders, scale, ref requiredCollidersCount);
|
||||
}
|
||||
DisposeExcessCollidersAfter(requiredCollidersCount);
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ namespace Spine.Unity {
|
||||
Slot slot = skeleton.FindSlot(slotName);
|
||||
if (slot != null) {
|
||||
int slotIndex = slot.Data.Index;
|
||||
bone = slot.bone;
|
||||
bone = slot.Bone;
|
||||
point = skeleton.GetAttachment(slotIndex, pointAttachmentName) as PointAttachment;
|
||||
}
|
||||
}
|
||||
@ -156,7 +156,7 @@ namespace Spine.Unity {
|
||||
|
||||
if (followSkeletonFlip) {
|
||||
Vector3 localScale = thisTransform.localScale;
|
||||
localScale.y = Mathf.Abs(localScale.y) * Mathf.Sign(bone.skeleton.ScaleX * bone.skeleton.ScaleY);
|
||||
localScale.y = Mathf.Abs(localScale.y) * Mathf.Sign(bone.Skeleton.ScaleX * bone.Skeleton.ScaleY);
|
||||
thisTransform.localScale = localScale;
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ namespace Spine.Unity {
|
||||
return Vector2.zero;
|
||||
|
||||
float start = time;
|
||||
float end = animation.duration;
|
||||
float end = animation.Duration;
|
||||
return GetAnimationRootMotion(start, end, animation);
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ namespace Spine.Unity {
|
||||
|
||||
var animation = track.Animation;
|
||||
float start = track.AnimationTime;
|
||||
float end = animation.duration;
|
||||
float end = animation.Duration;
|
||||
return GetAnimationRootMotion(start, end, animation);
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ namespace Spine.Unity {
|
||||
TrackEntry next = null;
|
||||
while (track != null) {
|
||||
var animation = track.Animation;
|
||||
float start = track.animationLast;
|
||||
float start = track.AnimationLast;
|
||||
float end = track.AnimationTime;
|
||||
var currentDelta = GetAnimationRootMotion(start, end, animation);
|
||||
if (currentDelta != Vector2.zero) {
|
||||
@ -122,7 +122,7 @@ namespace Spine.Unity {
|
||||
|
||||
// Traverse mixingFrom chain.
|
||||
next = track;
|
||||
track = track.mixingFrom;
|
||||
track = track.MixingFrom;
|
||||
}
|
||||
}
|
||||
return localDelta;
|
||||
@ -132,19 +132,19 @@ namespace Spine.Unity {
|
||||
// Apply mix alpha to the delta position (based on AnimationState.cs).
|
||||
float mix;
|
||||
if (next != null) {
|
||||
if (next.mixDuration == 0) { // Single frame mix to undo mixingFrom changes.
|
||||
if (next.MixDuration == 0) { // Single frame mix to undo mixingFrom changes.
|
||||
mix = 1;
|
||||
} else {
|
||||
mix = next.mixTime / next.mixDuration;
|
||||
mix = next.MixTime / next.MixDuration;
|
||||
if (mix > 1) mix = 1;
|
||||
}
|
||||
float mixAndAlpha = track.alpha * next.interruptAlpha * (1 - mix);
|
||||
float mixAndAlpha = track.Alpha * next.InterruptAlpha * (1 - mix);
|
||||
currentDelta *= mixAndAlpha;
|
||||
} else {
|
||||
if (track.mixDuration == 0) {
|
||||
if (track.MixDuration == 0) {
|
||||
mix = 1;
|
||||
} else {
|
||||
mix = track.alpha * (track.mixTime / track.mixDuration);
|
||||
mix = track.Alpha * (track.MixTime / track.MixDuration);
|
||||
if (mix > 1) mix = 1;
|
||||
}
|
||||
currentDelta *= mix;
|
||||
|
||||
@ -80,7 +80,7 @@ namespace Spine.Unity {
|
||||
GatherTopLevelBones();
|
||||
SetRootMotionBone(rootMotionBoneName);
|
||||
if (rootMotionBone != null)
|
||||
initialOffset = new Vector2(rootMotionBone.x, rootMotionBone.y);
|
||||
initialOffset = new Vector2(rootMotionBone.X, rootMotionBone.Y);
|
||||
|
||||
var skeletonAnimation = skeletonComponent as ISkeletonAnimation;
|
||||
if (skeletonAnimation != null) {
|
||||
@ -190,7 +190,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
public Vector2 GetAnimationRootMotion (Animation animation) {
|
||||
return GetAnimationRootMotion(0, animation.duration, animation);
|
||||
return GetAnimationRootMotion(0, animation.Duration, animation);
|
||||
}
|
||||
|
||||
public Vector2 GetAnimationRootMotion (float startTime, float endTime,
|
||||
@ -207,7 +207,7 @@ namespace Spine.Unity {
|
||||
RootMotionInfo rootMotion = new RootMotionInfo();
|
||||
var timeline = animation.FindTranslateTimelineForBone(rootMotionBoneIndex);
|
||||
if (timeline != null) {
|
||||
float duration = animation.duration;
|
||||
float duration = animation.Duration;
|
||||
float mid = duration * 0.5f;
|
||||
rootMotion.start = timeline.Evaluate(0);
|
||||
rootMotion.current = timeline.Evaluate(currentTime);
|
||||
@ -223,7 +223,7 @@ namespace Spine.Unity {
|
||||
|
||||
Vector2 currentDelta;
|
||||
if (startTime > endTime) // Looped
|
||||
currentDelta = (timeline.Evaluate(animation.duration) - timeline.Evaluate(startTime))
|
||||
currentDelta = (timeline.Evaluate(animation.Duration) - timeline.Evaluate(startTime))
|
||||
+ (timeline.Evaluate(endTime) - timeline.Evaluate(0));
|
||||
else if (startTime != endTime) // Non-looped
|
||||
currentDelta = timeline.Evaluate(endTime) - timeline.Evaluate(startTime);
|
||||
@ -280,7 +280,7 @@ namespace Spine.Unity {
|
||||
|
||||
parentBoneScale = Vector2.one;
|
||||
Bone scaleBone = rootMotionBone;
|
||||
while ((scaleBone = scaleBone.parent) != null) {
|
||||
while ((scaleBone = scaleBone.Parent) != null) {
|
||||
parentBoneScale.x *= scaleBone.ScaleX;
|
||||
parentBoneScale.y *= scaleBone.ScaleY;
|
||||
}
|
||||
@ -313,13 +313,13 @@ namespace Spine.Unity {
|
||||
var skeleton = skeletonComponent.Skeleton;
|
||||
foreach (var topLevelBone in topLevelBones) {
|
||||
if (topLevelBone == rootMotionBone) {
|
||||
if (transformPositionX) topLevelBone.x = displacementSkeletonSpace.x / skeleton.ScaleX;
|
||||
if (transformPositionY) topLevelBone.y = displacementSkeletonSpace.y / skeleton.ScaleY;
|
||||
if (transformPositionX) topLevelBone.X = displacementSkeletonSpace.x / skeleton.ScaleX;
|
||||
if (transformPositionY) topLevelBone.Y = displacementSkeletonSpace.y / skeleton.ScaleY;
|
||||
} else {
|
||||
float offsetX = (initialOffset.x - rootMotionBone.x) * parentBoneScale.x;
|
||||
float offsetY = (initialOffset.y - rootMotionBone.y) * parentBoneScale.y;
|
||||
if (transformPositionX) topLevelBone.x = (displacementSkeletonSpace.x / skeleton.ScaleX) + offsetX;
|
||||
if (transformPositionY) topLevelBone.y = (displacementSkeletonSpace.y / skeleton.ScaleY) + offsetY;
|
||||
float offsetX = (initialOffset.x - rootMotionBone.X) * parentBoneScale.x;
|
||||
float offsetY = (initialOffset.y - rootMotionBone.Y) * parentBoneScale.y;
|
||||
if (transformPositionX) topLevelBone.X = (displacementSkeletonSpace.x / skeleton.ScaleX) + offsetX;
|
||||
if (transformPositionY) topLevelBone.Y = (displacementSkeletonSpace.y / skeleton.ScaleY) + offsetY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ namespace Spine.Unity {
|
||||
Initialize(false);
|
||||
if (_animationName == value) {
|
||||
TrackEntry entry = state.GetCurrent(0);
|
||||
if (entry != null && entry.loop == loop)
|
||||
if (entry != null && entry.Loop == loop)
|
||||
return;
|
||||
}
|
||||
_animationName = value;
|
||||
|
||||
@ -108,7 +108,7 @@ namespace Spine.Unity {
|
||||
Clear();
|
||||
} else if (skeletonDataAsset.skeletonJSON == null) {
|
||||
Clear();
|
||||
} else if (skeletonDataAsset.GetSkeletonData(true) != skeleton.data) {
|
||||
} else if (skeletonDataAsset.GetSkeletonData(true) != skeleton.Data) {
|
||||
Clear();
|
||||
Initialize(true);
|
||||
if (!allowMultipleCanvasRenderers && (skeletonDataAsset.atlasAssets.Length > 1 || skeletonDataAsset.atlasAssets[0].MaterialCount > 1))
|
||||
@ -117,9 +117,9 @@ namespace Spine.Unity {
|
||||
if (freeze) return;
|
||||
|
||||
if (!string.IsNullOrEmpty(initialSkinName)) {
|
||||
var skin = skeleton.data.FindSkin(initialSkinName);
|
||||
var skin = skeleton.Data.FindSkin(initialSkinName);
|
||||
if (skin != null) {
|
||||
if (skin == skeleton.data.defaultSkin)
|
||||
if (skin == skeleton.Data.DefaultSkin)
|
||||
skeleton.SetSkin((Skin)null);
|
||||
else
|
||||
skeleton.SetSkin(skin);
|
||||
@ -378,7 +378,7 @@ namespace Spine.Unity {
|
||||
skeleton = value;
|
||||
}
|
||||
}
|
||||
public SkeletonData SkeletonData { get { return skeleton == null ? null : skeleton.data; } }
|
||||
public SkeletonData SkeletonData { get { return skeleton == null ? null : skeleton.Data; } }
|
||||
public bool IsValid { get { return skeleton != null; } }
|
||||
|
||||
public delegate void SkeletonRendererDelegate (SkeletonGraphic skeletonGraphic);
|
||||
|
||||
@ -270,9 +270,10 @@ namespace Spine.Unity {
|
||||
|
||||
float speedFactor = stateInfo.speedMultiplier * stateInfo.speed;
|
||||
float lastTime = time - (Time.deltaTime * speedFactor);
|
||||
if (isLooping && clip.duration != 0) {
|
||||
time %= clip.duration;
|
||||
lastTime %= clip.duration;
|
||||
float clipDuration = clip.Duration;
|
||||
if (isLooping && clipDuration != 0) {
|
||||
time %= clipDuration;
|
||||
lastTime %= clipDuration;
|
||||
}
|
||||
_OnClipApplied(clip, layerIndex, weight, time, lastTime, speedFactor < 0);
|
||||
}
|
||||
|
||||
@ -582,16 +582,16 @@ namespace Spine.Unity {
|
||||
if (clearExistingSeparators)
|
||||
separatorSlots.Clear();
|
||||
|
||||
var slots = skeleton.slots;
|
||||
var slots = skeleton.Slots;
|
||||
foreach (var slot in slots) {
|
||||
if (slotNamePredicate.Invoke(slot.data.name))
|
||||
if (slotNamePredicate.Invoke(slot.Data.Name))
|
||||
separatorSlots.Add(slot);
|
||||
}
|
||||
|
||||
if (updateStringArray) {
|
||||
var detectedSeparatorNames = new List<string>();
|
||||
foreach (var slot in skeleton.slots) {
|
||||
string slotName = slot.data.name;
|
||||
foreach (var slot in skeleton.Slots) {
|
||||
string slotName = slot.Data.Name;
|
||||
if (slotNamePredicate.Invoke(slotName))
|
||||
detectedSeparatorNames.Add(slotName);
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Spine.Unity {
|
||||
|
||||
#region BoundingBoxAttachment
|
||||
public static PolygonCollider2D AddBoundingBoxGameObject (Skeleton skeleton, string skinName, string slotName, string attachmentName, Transform parent, bool isTrigger = true) {
|
||||
Skin skin = string.IsNullOrEmpty(skinName) ? skeleton.data.defaultSkin : skeleton.data.FindSkin(skinName);
|
||||
Skin skin = string.IsNullOrEmpty(skinName) ? skeleton.Data.DefaultSkin : skeleton.Data.FindSkin(skinName);
|
||||
if (skin == null) {
|
||||
Debug.LogError("Skin " + skinName + " not found!");
|
||||
return null;
|
||||
@ -55,7 +55,7 @@ namespace Spine.Unity {
|
||||
|
||||
var attachment = skin.GetAttachment(skeleton.Data.FindSlot(slotName).Index, attachmentName);
|
||||
if (attachment == null) {
|
||||
Debug.LogFormat("Attachment in slot '{0}' named '{1}' not found in skin '{2}'.", slotName, attachmentName, skin.name);
|
||||
Debug.LogFormat("Attachment in slot '{0}' named '{1}' not found in skin '{2}'.", slotName, attachmentName, skin.Name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -310,11 +310,11 @@ namespace Spine.Unity {
|
||||
var constraintTargets = new List<System.Object>();
|
||||
var ikConstraints = skeleton.IkConstraints;
|
||||
for (int i = 0, n = ikConstraints.Count; i < n; i++)
|
||||
constraintTargets.Add(ikConstraints.Items[i].target);
|
||||
constraintTargets.Add(ikConstraints.Items[i].Target);
|
||||
|
||||
var transformConstraints = skeleton.TransformConstraints;
|
||||
for (int i = 0, n = transformConstraints.Count; i < n; i++)
|
||||
constraintTargets.Add(transformConstraints.Items[i].target);
|
||||
constraintTargets.Add(transformConstraints.Items[i].Target);
|
||||
|
||||
var boneComponents = this.boneComponents;
|
||||
for (int i = 0, n = boneComponents.Count; i < n; i++) {
|
||||
@ -456,7 +456,7 @@ namespace Spine.Unity {
|
||||
if (mode == SkeletonUtilityBone.Mode.Override) {
|
||||
if (rot) goTransform.localRotation = Quaternion.Euler(0, 0, b.bone.AppliedRotation);
|
||||
if (pos) goTransform.localPosition = new Vector3(b.bone.X * positionScale, b.bone.Y * positionScale, 0);
|
||||
goTransform.localScale = new Vector3(b.bone.scaleX, b.bone.scaleY, 0);
|
||||
goTransform.localScale = new Vector3(b.bone.ScaleX, b.bone.ScaleY, 0);
|
||||
}
|
||||
|
||||
return go;
|
||||
|
||||
@ -130,11 +130,11 @@ namespace Spine.Unity {
|
||||
switch (phase) {
|
||||
case UpdatePhase.Local:
|
||||
if (position)
|
||||
thisTransform.localPosition = new Vector3(bone.x * positionScale, bone.y * positionScale, 0);
|
||||
thisTransform.localPosition = new Vector3(bone.X * positionScale, bone.Y * positionScale, 0);
|
||||
|
||||
if (rotation) {
|
||||
if (bone.data.transformMode.InheritsRotation()) {
|
||||
thisTransform.localRotation = Quaternion.Euler(0, 0, bone.rotation);
|
||||
if (bone.Data.TransformMode.InheritsRotation()) {
|
||||
thisTransform.localRotation = Quaternion.Euler(0, 0, bone.Rotation);
|
||||
} else {
|
||||
Vector3 euler = skeletonTransform.rotation.eulerAngles;
|
||||
thisTransform.rotation = Quaternion.Euler(euler.x, euler.y, euler.z + (bone.WorldRotationX * skeletonFlipRotation));
|
||||
@ -142,17 +142,17 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
if (scale) {
|
||||
thisTransform.localScale = new Vector3(bone.scaleX, bone.scaleY, 1f);
|
||||
thisTransform.localScale = new Vector3(bone.ScaleX, bone.ScaleY, 1f);
|
||||
incompatibleTransformMode = BoneTransformModeIncompatible(bone);
|
||||
}
|
||||
break;
|
||||
case UpdatePhase.World:
|
||||
case UpdatePhase.Complete:
|
||||
if (position)
|
||||
thisTransform.localPosition = new Vector3(bone.ax * positionScale, bone.ay * positionScale, 0);
|
||||
thisTransform.localPosition = new Vector3(bone.AX * positionScale, bone.AY * positionScale, 0);
|
||||
|
||||
if (rotation) {
|
||||
if (bone.data.transformMode.InheritsRotation()) {
|
||||
if (bone.Data.TransformMode.InheritsRotation()) {
|
||||
thisTransform.localRotation = Quaternion.Euler(0, 0, bone.AppliedRotation);
|
||||
} else {
|
||||
Vector3 euler = skeletonTransform.rotation.eulerAngles;
|
||||
@ -161,7 +161,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
if (scale) {
|
||||
thisTransform.localScale = new Vector3(bone.ascaleX, bone.ascaleY, 1f);
|
||||
thisTransform.localScale = new Vector3(bone.AScaleX, bone.AScaleY, 1f);
|
||||
incompatibleTransformMode = BoneTransformModeIncompatible(bone);
|
||||
}
|
||||
break;
|
||||
@ -174,8 +174,8 @@ namespace Spine.Unity {
|
||||
if (parentReference == null) {
|
||||
if (position) {
|
||||
Vector3 clp = thisTransform.localPosition / positionScale;
|
||||
bone.x = Mathf.Lerp(bone.x, clp.x, overrideAlpha);
|
||||
bone.y = Mathf.Lerp(bone.y, clp.y, overrideAlpha);
|
||||
bone.X = Mathf.Lerp(bone.X, clp.x, overrideAlpha);
|
||||
bone.Y = Mathf.Lerp(bone.Y, clp.y, overrideAlpha);
|
||||
}
|
||||
|
||||
if (rotation) {
|
||||
@ -186,8 +186,8 @@ namespace Spine.Unity {
|
||||
|
||||
if (scale) {
|
||||
Vector3 cls = thisTransform.localScale;
|
||||
bone.scaleX = Mathf.Lerp(bone.scaleX, cls.x, overrideAlpha);
|
||||
bone.scaleY = Mathf.Lerp(bone.scaleY, cls.y, overrideAlpha);
|
||||
bone.ScaleX = Mathf.Lerp(bone.ScaleX, cls.x, overrideAlpha);
|
||||
bone.ScaleY = Mathf.Lerp(bone.ScaleY, cls.y, overrideAlpha);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -196,8 +196,8 @@ namespace Spine.Unity {
|
||||
|
||||
if (position) {
|
||||
Vector3 pos = parentReference.InverseTransformPoint(thisTransform.position) / positionScale;
|
||||
bone.x = Mathf.Lerp(bone.x, pos.x, overrideAlpha);
|
||||
bone.y = Mathf.Lerp(bone.y, pos.y, overrideAlpha);
|
||||
bone.X = Mathf.Lerp(bone.X, pos.x, overrideAlpha);
|
||||
bone.Y = Mathf.Lerp(bone.Y, pos.y, overrideAlpha);
|
||||
}
|
||||
|
||||
if (rotation) {
|
||||
@ -208,8 +208,8 @@ namespace Spine.Unity {
|
||||
|
||||
if (scale) {
|
||||
Vector3 cls = thisTransform.localScale;
|
||||
bone.scaleX = Mathf.Lerp(bone.scaleX, cls.x, overrideAlpha);
|
||||
bone.scaleY = Mathf.Lerp(bone.scaleY, cls.y, overrideAlpha);
|
||||
bone.ScaleX = Mathf.Lerp(bone.ScaleX, cls.x, overrideAlpha);
|
||||
bone.ScaleY = Mathf.Lerp(bone.ScaleY, cls.y, overrideAlpha);
|
||||
}
|
||||
|
||||
incompatibleTransformMode = BoneTransformModeIncompatible(bone);
|
||||
@ -220,12 +220,12 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
public static bool BoneTransformModeIncompatible (Bone bone) {
|
||||
return !bone.data.transformMode.InheritsScale();
|
||||
return !bone.Data.TransformMode.InheritsScale();
|
||||
}
|
||||
|
||||
public void AddBoundingBox (string skinName, string slotName, string attachmentName) {
|
||||
SkeletonUtility.AddBoneRigidbody2D(transform.gameObject);
|
||||
SkeletonUtility.AddBoundingBoxGameObject(bone.skeleton, skinName, slotName, attachmentName, transform);
|
||||
SkeletonUtility.AddBoundingBoxGameObject(bone.Skeleton, skinName, slotName, attachmentName, transform);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
@ -149,7 +149,7 @@ namespace Spine.Unity {
|
||||
/// <param name="material">Material to be set at the renderer instruction. When null, the last attachment
|
||||
/// in the draw order list is assigned as the instruction's material.</param>
|
||||
public static void GenerateSingleSubmeshInstruction (SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Material material) {
|
||||
ExposedList<Slot> drawOrder = skeleton.drawOrder;
|
||||
ExposedList<Slot> drawOrder = skeleton.DrawOrder;
|
||||
int drawOrderCount = drawOrder.Count;
|
||||
|
||||
// Clear last state of attachments and submeshes
|
||||
@ -180,9 +180,9 @@ namespace Spine.Unity {
|
||||
var drawOrderItems = drawOrder.Items;
|
||||
for (int i = 0; i < drawOrderCount; i++) {
|
||||
Slot slot = drawOrderItems[i];
|
||||
if (!slot.bone.active) continue;
|
||||
if (slot.data.blendMode == BlendMode.Additive) current.hasPMAAdditiveSlot = true;
|
||||
Attachment attachment = slot.attachment;
|
||||
if (!slot.Bone.Active) continue;
|
||||
if (slot.Data.BlendMode == BlendMode.Additive) current.hasPMAAdditiveSlot = true;
|
||||
Attachment attachment = slot.Attachment;
|
||||
|
||||
workingAttachmentsItems[i] = attachment;
|
||||
int attachmentTriangleCount;
|
||||
@ -197,8 +197,8 @@ namespace Spine.Unity {
|
||||
var meshAttachment = attachment as MeshAttachment;
|
||||
if (meshAttachment != null) {
|
||||
rendererObject = meshAttachment.RendererObject;
|
||||
attachmentVertexCount = meshAttachment.worldVerticesLength >> 1;
|
||||
attachmentTriangleCount = meshAttachment.triangles.Length;
|
||||
attachmentVertexCount = meshAttachment.WorldVerticesLength >> 1;
|
||||
attachmentTriangleCount = meshAttachment.Triangles.Length;
|
||||
} else {
|
||||
var clippingAttachment = attachment as ClippingAttachment;
|
||||
if (clippingAttachment != null) {
|
||||
@ -239,15 +239,15 @@ namespace Spine.Unity {
|
||||
#if SPINE_TK2D
|
||||
return false;
|
||||
#endif
|
||||
ExposedList<Slot> drawOrder = skeleton.drawOrder;
|
||||
ExposedList<Slot> drawOrder = skeleton.DrawOrder;
|
||||
int drawOrderCount = drawOrder.Count;
|
||||
var drawOrderItems = drawOrder.Items;
|
||||
|
||||
Material lastRendererMaterial = null;
|
||||
for (int i = 0; i < drawOrderCount; i++) {
|
||||
Slot slot = drawOrderItems[i];
|
||||
if (!slot.bone.active) continue;
|
||||
Attachment attachment = slot.attachment;
|
||||
if (!slot.Bone.Active) continue;
|
||||
Attachment attachment = slot.Attachment;
|
||||
var rendererAttachment = attachment as IHasRendererObject;
|
||||
if (rendererAttachment != null) {
|
||||
AtlasRegion atlasRegion = (AtlasRegion)rendererAttachment.RendererObject;
|
||||
@ -267,7 +267,7 @@ namespace Spine.Unity {
|
||||
// if (skeleton == null) throw new ArgumentNullException("skeleton");
|
||||
// if (instructionOutput == null) throw new ArgumentNullException("instructionOutput");
|
||||
|
||||
ExposedList<Slot> drawOrder = skeleton.drawOrder;
|
||||
ExposedList<Slot> drawOrder = skeleton.DrawOrder;
|
||||
int drawOrderCount = drawOrder.Count;
|
||||
|
||||
// Clear last state of attachments and submeshes
|
||||
@ -299,9 +299,9 @@ namespace Spine.Unity {
|
||||
var drawOrderItems = drawOrder.Items;
|
||||
for (int i = 0; i < drawOrderCount; i++) {
|
||||
Slot slot = drawOrderItems[i];
|
||||
if (!slot.bone.active) continue;
|
||||
if (slot.data.blendMode == BlendMode.Additive) current.hasPMAAdditiveSlot = true;
|
||||
Attachment attachment = slot.attachment;
|
||||
if (!slot.Bone.Active) continue;
|
||||
if (slot.Data.BlendMode == BlendMode.Additive) current.hasPMAAdditiveSlot = true;
|
||||
Attachment attachment = slot.Attachment;
|
||||
#if SPINE_TRIANGLECHECK
|
||||
workingAttachmentsItems[i] = attachment;
|
||||
int attachmentVertexCount = 0, attachmentTriangleCount = 0;
|
||||
@ -322,14 +322,14 @@ namespace Spine.Unity {
|
||||
if (meshAttachment != null) {
|
||||
rendererObject = meshAttachment.RendererObject;
|
||||
#if SPINE_TRIANGLECHECK
|
||||
attachmentVertexCount = meshAttachment.worldVerticesLength >> 1;
|
||||
attachmentTriangleCount = meshAttachment.triangles.Length;
|
||||
attachmentVertexCount = meshAttachment.WorldVerticesLength >> 1;
|
||||
attachmentTriangleCount = meshAttachment.Triangles.Length;
|
||||
#endif
|
||||
} else {
|
||||
#if SPINE_TRIANGLECHECK
|
||||
var clippingAttachment = attachment as ClippingAttachment;
|
||||
if (clippingAttachment != null) {
|
||||
clippingEndSlot = clippingAttachment.endSlot;
|
||||
clippingEndSlot = clippingAttachment.EndSlot;
|
||||
clippingAttachmentSource = i;
|
||||
current.hasClipping = true;
|
||||
skeletonHasClipping = true;
|
||||
@ -414,7 +414,7 @@ namespace Spine.Unity {
|
||||
#endif
|
||||
}
|
||||
|
||||
if (clippingEndSlot != null && slot.data == clippingEndSlot && i != clippingAttachmentSource) {
|
||||
if (clippingEndSlot != null && slot.Data == clippingEndSlot && i != clippingAttachmentSource) {
|
||||
clippingEndSlot = null;
|
||||
clippingAttachmentSource = -1;
|
||||
}
|
||||
@ -486,10 +486,10 @@ namespace Spine.Unity {
|
||||
submesh.Clear(false);
|
||||
|
||||
var skeleton = instruction.skeleton;
|
||||
var drawOrderItems = skeleton.drawOrder.Items;
|
||||
var drawOrderItems = skeleton.DrawOrder.Items;
|
||||
|
||||
Color32 color = default(Color32);
|
||||
float skeletonA = skeleton.a, skeletonR = skeleton.r, skeletonG = skeleton.g, skeletonB = skeleton.b;
|
||||
float skeletonA = skeleton.A, skeletonR = skeleton.R, skeletonG = skeleton.G, skeletonB = skeleton.B;
|
||||
Vector2 meshBoundsMin = this.meshBoundsMin, meshBoundsMax = this.meshBoundsMax;
|
||||
|
||||
// Settings
|
||||
@ -506,17 +506,17 @@ namespace Spine.Unity {
|
||||
if (useClipping) {
|
||||
if (instruction.preActiveClippingSlotSource >= 0) {
|
||||
var slot = drawOrderItems[instruction.preActiveClippingSlotSource];
|
||||
clipper.ClipStart(slot, slot.attachment as ClippingAttachment);
|
||||
clipper.ClipStart(slot, slot.Attachment as ClippingAttachment);
|
||||
}
|
||||
}
|
||||
|
||||
for (int slotIndex = instruction.startSlot; slotIndex < instruction.endSlot; slotIndex++) {
|
||||
var slot = drawOrderItems[slotIndex];
|
||||
if (!slot.bone.active) {
|
||||
if (!slot.Bone.Active) {
|
||||
clipper.ClipEnd(slot);
|
||||
continue;
|
||||
}
|
||||
var attachment = slot.attachment;
|
||||
var attachment = slot.Attachment;
|
||||
float z = zSpacing * slotIndex;
|
||||
|
||||
var workingVerts = this.tempVerts;
|
||||
@ -530,26 +530,26 @@ namespace Spine.Unity {
|
||||
// Identify and prepare values.
|
||||
var region = attachment as RegionAttachment;
|
||||
if (region != null) {
|
||||
region.ComputeWorldVertices(slot.bone, workingVerts, 0);
|
||||
uvs = region.uvs;
|
||||
region.ComputeWorldVertices(slot.Bone, workingVerts, 0);
|
||||
uvs = region.UVs;
|
||||
attachmentTriangleIndices = regionTriangles;
|
||||
c.r = region.r; c.g = region.g; c.b = region.b; c.a = region.a;
|
||||
c.r = region.R; c.g = region.G; c.b = region.B; c.a = region.A;
|
||||
attachmentVertexCount = 4;
|
||||
attachmentIndexCount = 6;
|
||||
} else {
|
||||
var mesh = attachment as MeshAttachment;
|
||||
if (mesh != null) {
|
||||
int meshVerticesLength = mesh.worldVerticesLength;
|
||||
int meshVerticesLength = mesh.WorldVerticesLength;
|
||||
if (workingVerts.Length < meshVerticesLength) {
|
||||
workingVerts = new float[meshVerticesLength];
|
||||
this.tempVerts = workingVerts;
|
||||
}
|
||||
mesh.ComputeWorldVertices(slot, 0, meshVerticesLength, workingVerts, 0); //meshAttachment.ComputeWorldVertices(slot, tempVerts);
|
||||
uvs = mesh.uvs;
|
||||
attachmentTriangleIndices = mesh.triangles;
|
||||
c.r = mesh.r; c.g = mesh.g; c.b = mesh.b; c.a = mesh.a;
|
||||
uvs = mesh.UVs;
|
||||
attachmentTriangleIndices = mesh.Triangles;
|
||||
c.r = mesh.R; c.g = mesh.G; c.b = mesh.B; c.a = mesh.A;
|
||||
attachmentVertexCount = meshVerticesLength >> 1; // meshVertexCount / 2;
|
||||
attachmentIndexCount = mesh.triangles.Length;
|
||||
attachmentIndexCount = mesh.Triangles.Length;
|
||||
} else {
|
||||
if (useClipping) {
|
||||
var clippingAttachment = attachment as ClippingAttachment;
|
||||
@ -567,12 +567,12 @@ namespace Spine.Unity {
|
||||
|
||||
float tintBlackAlpha = 1.0f;
|
||||
if (pmaVertexColors) {
|
||||
float colorA = skeletonA * slot.a * c.a;
|
||||
float colorA = skeletonA * slot.A * c.a;
|
||||
color.a = (byte)(colorA * 255);
|
||||
color.r = (byte)(skeletonR * slot.r * c.r * color.a);
|
||||
color.g = (byte)(skeletonG * slot.g * c.g * color.a);
|
||||
color.b = (byte)(skeletonB * slot.b * c.b * color.a);
|
||||
if (slot.data.blendMode == BlendMode.Additive) {
|
||||
color.r = (byte)(skeletonR * slot.R * c.r * color.a);
|
||||
color.g = (byte)(skeletonG * slot.G * c.g * color.a);
|
||||
color.b = (byte)(skeletonB * slot.B * c.b * color.a);
|
||||
if (slot.Data.BlendMode == BlendMode.Additive) {
|
||||
if (canvasGroupTintBlack)
|
||||
tintBlackAlpha = 0;
|
||||
else
|
||||
@ -581,29 +581,29 @@ namespace Spine.Unity {
|
||||
tintBlackAlpha = colorA;
|
||||
}
|
||||
} else {
|
||||
color.a = (byte)(skeletonA * slot.a * c.a * 255);
|
||||
color.r = (byte)(skeletonR * slot.r * c.r * 255);
|
||||
color.g = (byte)(skeletonG * slot.g * c.g * 255);
|
||||
color.b = (byte)(skeletonB * slot.b * c.b * 255);
|
||||
color.a = (byte)(skeletonA * slot.A * c.a * 255);
|
||||
color.r = (byte)(skeletonR * slot.R * c.r * 255);
|
||||
color.g = (byte)(skeletonG * slot.G * c.g * 255);
|
||||
color.b = (byte)(skeletonB * slot.B * c.b * 255);
|
||||
}
|
||||
|
||||
if (useClipping && clipper.IsClipping) {
|
||||
clipper.ClipTriangles(workingVerts, attachmentVertexCount << 1, attachmentTriangleIndices, attachmentIndexCount, uvs);
|
||||
workingVerts = clipper.clippedVertices.Items;
|
||||
attachmentVertexCount = clipper.clippedVertices.Count >> 1;
|
||||
attachmentTriangleIndices = clipper.clippedTriangles.Items;
|
||||
attachmentIndexCount = clipper.clippedTriangles.Count;
|
||||
uvs = clipper.clippedUVs.Items;
|
||||
workingVerts = clipper.ClippedVertices.Items;
|
||||
attachmentVertexCount = clipper.ClippedVertices.Count >> 1;
|
||||
attachmentTriangleIndices = clipper.ClippedTriangles.Items;
|
||||
attachmentIndexCount = clipper.ClippedTriangles.Count;
|
||||
uvs = clipper.ClippedUVs.Items;
|
||||
}
|
||||
|
||||
// Actually add slot/attachment data into buffers.
|
||||
if (attachmentVertexCount != 0 && attachmentIndexCount != 0) {
|
||||
if (tintBlack) {
|
||||
float r2 = slot.r2;
|
||||
float g2 = slot.g2;
|
||||
float b2 = slot.b2;
|
||||
float r2 = slot.R2;
|
||||
float g2 = slot.G2;
|
||||
float b2 = slot.B2;
|
||||
if (pmaVertexColors) {
|
||||
float alpha = skeletonA * slot.a * c.a;
|
||||
float alpha = skeletonA * slot.A * c.a;
|
||||
r2 *= alpha;
|
||||
g2 *= alpha;
|
||||
b2 *= alpha;
|
||||
@ -742,8 +742,8 @@ namespace Spine.Unity {
|
||||
for (int si = 0, n = instruction.submeshInstructions.Count; si < n; si++) {
|
||||
var submesh = instruction.submeshInstructions.Items[si];
|
||||
var skeleton = submesh.skeleton;
|
||||
var drawOrderItems = skeleton.drawOrder.Items;
|
||||
float a = skeleton.a, r = skeleton.r, g = skeleton.g, b = skeleton.b;
|
||||
var drawOrderItems = skeleton.DrawOrder.Items;
|
||||
float a = skeleton.A, r = skeleton.R, g = skeleton.G, b = skeleton.B;
|
||||
|
||||
int endSlot = submesh.endSlot;
|
||||
int startSlot = submesh.startSlot;
|
||||
@ -771,22 +771,22 @@ namespace Spine.Unity {
|
||||
|
||||
for (int slotIndex = startSlot; slotIndex < endSlot; slotIndex++) {
|
||||
var slot = drawOrderItems[slotIndex];
|
||||
if (!slot.bone.active) continue;
|
||||
var attachment = slot.attachment;
|
||||
if (!slot.Bone.Active) continue;
|
||||
var attachment = slot.Attachment;
|
||||
|
||||
rg.x = slot.r2; //r
|
||||
rg.y = slot.g2; //g
|
||||
b2.x = slot.b2; //b
|
||||
rg.x = slot.R2; //r
|
||||
rg.y = slot.G2; //g
|
||||
b2.x = slot.B2; //b
|
||||
b2.y = 1.0f;
|
||||
|
||||
var regionAttachment = attachment as RegionAttachment;
|
||||
if (regionAttachment != null) {
|
||||
if (settings.pmaVertexColors) {
|
||||
float alpha = a * slot.a * regionAttachment.a;
|
||||
float alpha = a * slot.A * regionAttachment.A;
|
||||
rg.x *= alpha;
|
||||
rg.y *= alpha;
|
||||
b2.x *= alpha;
|
||||
b2.y = slot.data.blendMode == BlendMode.Additive ? 0 : alpha;
|
||||
b2.y = slot.Data.BlendMode == BlendMode.Additive ? 0 : alpha;
|
||||
}
|
||||
uv2i[vi] = rg; uv2i[vi + 1] = rg; uv2i[vi + 2] = rg; uv2i[vi + 3] = rg;
|
||||
uv3i[vi] = b2; uv3i[vi + 1] = b2; uv3i[vi + 2] = b2; uv3i[vi + 3] = b2;
|
||||
@ -795,13 +795,13 @@ namespace Spine.Unity {
|
||||
var meshAttachment = attachment as MeshAttachment;
|
||||
if (meshAttachment != null) {
|
||||
if (settings.pmaVertexColors) {
|
||||
float alpha = a * slot.a * meshAttachment.a;
|
||||
float alpha = a * slot.A * meshAttachment.A;
|
||||
rg.x *= alpha;
|
||||
rg.y *= alpha;
|
||||
b2.x *= alpha;
|
||||
b2.y = slot.data.blendMode == BlendMode.Additive ? 0 : alpha;
|
||||
b2.y = slot.Data.BlendMode == BlendMode.Additive ? 0 : alpha;
|
||||
}
|
||||
int meshVertexCount = meshAttachment.worldVerticesLength;
|
||||
int meshVertexCount = meshAttachment.WorldVerticesLength;
|
||||
for (int iii = 0; iii < meshVertexCount; iii += 2) {
|
||||
uv2i[vi] = rg;
|
||||
uv3i[vi] = b2;
|
||||
@ -814,13 +814,13 @@ namespace Spine.Unity {
|
||||
|
||||
for (int slotIndex = startSlot; slotIndex < endSlot; slotIndex++) {
|
||||
var slot = drawOrderItems[slotIndex];
|
||||
if (!slot.bone.active) continue;
|
||||
var attachment = slot.attachment;
|
||||
if (!slot.Bone.Active) continue;
|
||||
var attachment = slot.Attachment;
|
||||
float z = slotIndex * settings.zSpacing;
|
||||
|
||||
var regionAttachment = attachment as RegionAttachment;
|
||||
if (regionAttachment != null) {
|
||||
regionAttachment.ComputeWorldVertices(slot.bone, tempVerts, 0);
|
||||
regionAttachment.ComputeWorldVertices(slot.Bone, tempVerts, 0);
|
||||
|
||||
float x1 = tempVerts[RegionAttachment.BLX], y1 = tempVerts[RegionAttachment.BLY];
|
||||
float x2 = tempVerts[RegionAttachment.ULX], y2 = tempVerts[RegionAttachment.ULY];
|
||||
@ -832,21 +832,21 @@ namespace Spine.Unity {
|
||||
vbi[vertexIndex + 3].x = x3; vbi[vertexIndex + 3].y = y3; vbi[vertexIndex + 3].z = z;
|
||||
|
||||
if (settings.pmaVertexColors) {
|
||||
color.a = (byte)(a * slot.a * regionAttachment.a * 255);
|
||||
color.r = (byte)(r * slot.r * regionAttachment.r * color.a);
|
||||
color.g = (byte)(g * slot.g * regionAttachment.g * color.a);
|
||||
color.b = (byte)(b * slot.b * regionAttachment.b * color.a);
|
||||
if (slot.data.blendMode == BlendMode.Additive && !canvasGroupTintBlack) color.a = 0;
|
||||
color.a = (byte)(a * slot.A * regionAttachment.A * 255);
|
||||
color.r = (byte)(r * slot.R * regionAttachment.R * color.a);
|
||||
color.g = (byte)(g * slot.G * regionAttachment.G * color.a);
|
||||
color.b = (byte)(b * slot.B * regionAttachment.B * color.a);
|
||||
if (slot.Data.BlendMode == BlendMode.Additive && !canvasGroupTintBlack) color.a = 0;
|
||||
} else {
|
||||
color.a = (byte)(a * slot.a * regionAttachment.a * 255);
|
||||
color.r = (byte)(r * slot.r * regionAttachment.r * 255);
|
||||
color.g = (byte)(g * slot.g * regionAttachment.g * 255);
|
||||
color.b = (byte)(b * slot.b * regionAttachment.b * 255);
|
||||
color.a = (byte)(a * slot.A * regionAttachment.A * 255);
|
||||
color.r = (byte)(r * slot.R * regionAttachment.R * 255);
|
||||
color.g = (byte)(g * slot.G * regionAttachment.G * 255);
|
||||
color.b = (byte)(b * slot.B * regionAttachment.B * 255);
|
||||
}
|
||||
|
||||
cbi[vertexIndex] = color; cbi[vertexIndex + 1] = color; cbi[vertexIndex + 2] = color; cbi[vertexIndex + 3] = color;
|
||||
|
||||
float[] regionUVs = regionAttachment.uvs;
|
||||
float[] regionUVs = regionAttachment.UVs;
|
||||
ubi[vertexIndex].x = regionUVs[RegionAttachment.BLX]; ubi[vertexIndex].y = regionUVs[RegionAttachment.BLY];
|
||||
ubi[vertexIndex + 1].x = regionUVs[RegionAttachment.BRX]; ubi[vertexIndex + 1].y = regionUVs[RegionAttachment.BRY];
|
||||
ubi[vertexIndex + 2].x = regionUVs[RegionAttachment.ULX]; ubi[vertexIndex + 2].y = regionUVs[RegionAttachment.ULY];
|
||||
@ -874,24 +874,24 @@ namespace Spine.Unity {
|
||||
} else { //if (settings.renderMeshes) {
|
||||
var meshAttachment = attachment as MeshAttachment;
|
||||
if (meshAttachment != null) {
|
||||
int meshVertexCount = meshAttachment.worldVerticesLength;
|
||||
int meshVertexCount = meshAttachment.WorldVerticesLength;
|
||||
if (tempVerts.Length < meshVertexCount) this.tempVerts = tempVerts = new float[meshVertexCount];
|
||||
meshAttachment.ComputeWorldVertices(slot, tempVerts);
|
||||
|
||||
if (settings.pmaVertexColors) {
|
||||
color.a = (byte)(a * slot.a * meshAttachment.a * 255);
|
||||
color.r = (byte)(r * slot.r * meshAttachment.r * color.a);
|
||||
color.g = (byte)(g * slot.g * meshAttachment.g * color.a);
|
||||
color.b = (byte)(b * slot.b * meshAttachment.b * color.a);
|
||||
if (slot.data.blendMode == BlendMode.Additive && !canvasGroupTintBlack) color.a = 0;
|
||||
color.a = (byte)(a * slot.A * meshAttachment.A * 255);
|
||||
color.r = (byte)(r * slot.R * meshAttachment.R * color.a);
|
||||
color.g = (byte)(g * slot.G * meshAttachment.G * color.a);
|
||||
color.b = (byte)(b * slot.B * meshAttachment.B * color.a);
|
||||
if (slot.Data.BlendMode == BlendMode.Additive && !canvasGroupTintBlack) color.a = 0;
|
||||
} else {
|
||||
color.a = (byte)(a * slot.a * meshAttachment.a * 255);
|
||||
color.r = (byte)(r * slot.r * meshAttachment.r * 255);
|
||||
color.g = (byte)(g * slot.g * meshAttachment.g * 255);
|
||||
color.b = (byte)(b * slot.b * meshAttachment.b * 255);
|
||||
color.a = (byte)(a * slot.A * meshAttachment.A * 255);
|
||||
color.r = (byte)(r * slot.R * meshAttachment.R * 255);
|
||||
color.g = (byte)(g * slot.G * meshAttachment.G * 255);
|
||||
color.b = (byte)(b * slot.B * meshAttachment.B * 255);
|
||||
}
|
||||
|
||||
float[] attachmentUVs = meshAttachment.uvs;
|
||||
float[] attachmentUVs = meshAttachment.UVs;
|
||||
|
||||
// Potential first attachment bounds initialization. See conditions in RegionAttachment logic.
|
||||
if (vertexIndex == 0) {
|
||||
@ -967,12 +967,12 @@ namespace Spine.Unity {
|
||||
var tris = currentSubmeshBuffer.Items;
|
||||
int triangleIndex = 0;
|
||||
var skeleton = submeshInstruction.skeleton;
|
||||
var drawOrderItems = skeleton.drawOrder.Items;
|
||||
var drawOrderItems = skeleton.DrawOrder.Items;
|
||||
for (int slotIndex = submeshInstruction.startSlot, endSlot = submeshInstruction.endSlot; slotIndex < endSlot; slotIndex++) {
|
||||
var slot = drawOrderItems[slotIndex];
|
||||
if (!slot.bone.active) continue;
|
||||
if (!slot.Bone.Active) continue;
|
||||
|
||||
var attachment = drawOrderItems[slotIndex].attachment;
|
||||
var attachment = drawOrderItems[slotIndex].Attachment;
|
||||
if (attachment is RegionAttachment) {
|
||||
tris[triangleIndex] = attachmentFirstVertex;
|
||||
tris[triangleIndex + 1] = attachmentFirstVertex + 2;
|
||||
@ -986,10 +986,10 @@ namespace Spine.Unity {
|
||||
}
|
||||
var meshAttachment = attachment as MeshAttachment;
|
||||
if (meshAttachment != null) {
|
||||
int[] attachmentTriangles = meshAttachment.triangles;
|
||||
int[] attachmentTriangles = meshAttachment.Triangles;
|
||||
for (int ii = 0, nn = attachmentTriangles.Length; ii < nn; ii++, triangleIndex++)
|
||||
tris[triangleIndex] = attachmentFirstVertex + attachmentTriangles[ii];
|
||||
attachmentFirstVertex += meshAttachment.worldVerticesLength >> 1; // length/2;
|
||||
attachmentFirstVertex += meshAttachment.WorldVerticesLength >> 1; // length/2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1294,7 +1294,7 @@ namespace Spine.Unity {
|
||||
AttachmentUVs.Add(new Vector2(uvs[RegionAttachment.BLX], uvs[RegionAttachment.BLY]));
|
||||
|
||||
AttachmentColors32.Clear();
|
||||
Color32 c = (Color32)(new Color(regionAttachment.r, regionAttachment.g, regionAttachment.b, regionAttachment.a));
|
||||
Color32 c = (Color32)(new Color(regionAttachment.R, regionAttachment.G, regionAttachment.B, regionAttachment.A));
|
||||
for (int i = 0; i < 4; i++)
|
||||
AttachmentColors32.Add(c);
|
||||
|
||||
@ -1323,16 +1323,16 @@ namespace Spine.Unity {
|
||||
AttachmentVerts.Clear();
|
||||
if (meshAttachment.IsWeighted()) {
|
||||
int count = meshAttachment.WorldVerticesLength;
|
||||
int[] meshAttachmentBones = meshAttachment.bones;
|
||||
int[] meshAttachmentBones = meshAttachment.Bones;
|
||||
int v = 0;
|
||||
|
||||
float[] vertices = meshAttachment.vertices;
|
||||
float[] vertices = meshAttachment.Vertices;
|
||||
for (int w = 0, b = 0; w < count; w += 2) {
|
||||
float wx = 0, wy = 0;
|
||||
int n = meshAttachmentBones[v++];
|
||||
n += v;
|
||||
for (; v < n; v++, b += 3) {
|
||||
BoneMatrix bm = BoneMatrix.CalculateSetupWorld(skeletonData.bones.Items[meshAttachmentBones[v]]);
|
||||
BoneMatrix bm = BoneMatrix.CalculateSetupWorld(skeletonData.Bones.Items[meshAttachmentBones[v]]);
|
||||
float vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2];
|
||||
wx += (vx * bm.a + vy * bm.b + bm.x) * weight;
|
||||
wy += (vx * bm.c + vy * bm.d + bm.y) * weight;
|
||||
@ -1350,9 +1350,9 @@ namespace Spine.Unity {
|
||||
}
|
||||
}
|
||||
|
||||
var uvs = meshAttachment.uvs;
|
||||
var uvs = meshAttachment.UVs;
|
||||
Vector2 uv = default(Vector2);
|
||||
Color32 c = (Color32)(new Color(meshAttachment.r, meshAttachment.g, meshAttachment.b, meshAttachment.a));
|
||||
Color32 c = (Color32)(new Color(meshAttachment.R, meshAttachment.G, meshAttachment.B, meshAttachment.A));
|
||||
AttachmentUVs.Clear();
|
||||
AttachmentColors32.Clear();
|
||||
for (int i = 0; i < vertexCount; i++) {
|
||||
@ -1365,7 +1365,7 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
AttachmentIndices.Clear();
|
||||
AttachmentIndices.AddRange(meshAttachment.triangles);
|
||||
AttachmentIndices.AddRange(meshAttachment.Triangles);
|
||||
|
||||
mesh.Clear();
|
||||
mesh.name = meshAttachment.Name;
|
||||
|
||||
@ -92,11 +92,11 @@ namespace Spine.Unity {
|
||||
attachments.Resize(attachmentCount);
|
||||
var attachmentsItems = attachments.Items;
|
||||
|
||||
var drawOrderItems = instructionsItems[0].skeleton.drawOrder.Items;
|
||||
var drawOrderItems = instructionsItems[0].skeleton.DrawOrder.Items;
|
||||
for (int i = 0; i < attachmentCount; i++) {
|
||||
Slot slot = drawOrderItems[startSlot + i];
|
||||
if (!slot.bone.active) continue;
|
||||
attachmentsItems[i] = slot.attachment;
|
||||
if (!slot.Bone.Active) continue;
|
||||
attachmentsItems[i] = slot.Attachment;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -55,15 +55,15 @@ namespace Spine.Unity {
|
||||
var slotsItems = skeletonData.Slots.Items;
|
||||
for (int slotIndex = 0, slotCount = skeletonData.Slots.Count; slotIndex < slotCount; slotIndex++) {
|
||||
var slot = slotsItems[slotIndex];
|
||||
if (slot.blendMode == BlendMode.Normal) continue;
|
||||
if (!includeAdditiveSlots && slot.blendMode == BlendMode.Additive) continue;
|
||||
if (slot.BlendMode == BlendMode.Normal) continue;
|
||||
if (!includeAdditiveSlots && slot.BlendMode == BlendMode.Additive) continue;
|
||||
|
||||
entryBuffer.Clear();
|
||||
foreach (var skin in skeletonData.Skins)
|
||||
skin.GetAttachments(slotIndex, entryBuffer);
|
||||
|
||||
Material templateMaterial = null;
|
||||
switch (slot.blendMode) {
|
||||
switch (slot.BlendMode) {
|
||||
case BlendMode.Multiply:
|
||||
templateMaterial = multiplyTemplate;
|
||||
break;
|
||||
|
||||
@ -497,12 +497,12 @@ namespace Spine.Unity.AttachmentTools {
|
||||
var skinAttachments = o.Attachments;
|
||||
var newSkin = new Skin(newName);
|
||||
|
||||
newSkin.bones.AddRange(o.bones);
|
||||
newSkin.constraints.AddRange(o.constraints);
|
||||
newSkin.Bones.AddRange(o.Bones);
|
||||
newSkin.Constraints.AddRange(o.Constraints);
|
||||
|
||||
inoutAttachments.Clear();
|
||||
foreach (var entry in o.Attachments) {
|
||||
inoutAttachments.Add(entry.attachment);
|
||||
inoutAttachments.Add(entry.Attachment);
|
||||
}
|
||||
GetRepackedAttachments(inoutAttachments, inoutAttachments, materialPropertySource, out outputMaterial, out outputTexture,
|
||||
maxAtlasSize, padding, textureFormat, mipmaps, newName, clearCache, useOriginalNonrenderables,
|
||||
|
||||
@ -69,7 +69,7 @@ namespace Spine.Unity.AttachmentTools {
|
||||
if (useOriginalRegionScale) {
|
||||
var regionAttachment = o as RegionAttachment;
|
||||
if (regionAttachment != null)
|
||||
scale = regionAttachment.width / regionAttachment.regionOriginalWidth;
|
||||
scale = regionAttachment.Width / regionAttachment.RegionOriginalWidth;
|
||||
}
|
||||
return o.GetRemappedClone(atlasRegion, cloneMeshAsLinked, useOriginalRegionSize, scale);
|
||||
}
|
||||
@ -88,8 +88,8 @@ namespace Spine.Unity.AttachmentTools {
|
||||
RegionAttachment newAttachment = (RegionAttachment)regionAttachment.Copy();
|
||||
newAttachment.SetRegion(atlasRegion, false);
|
||||
if (!useOriginalRegionSize) {
|
||||
newAttachment.width = atlasRegion.width * scale;
|
||||
newAttachment.height = atlasRegion.height * scale;
|
||||
newAttachment.Width = atlasRegion.width * scale;
|
||||
newAttachment.Height = atlasRegion.height * scale;
|
||||
}
|
||||
newAttachment.UpdateOffset();
|
||||
return newAttachment;
|
||||
|
||||
@ -53,12 +53,12 @@ namespace Spine.Unity.AttachmentTools {
|
||||
// (AtlasAttachmentLoader.cs)
|
||||
attachment.RendererObject = region;
|
||||
attachment.SetUVs(region.u, region.v, region.u2, region.v2, region.degrees);
|
||||
attachment.regionOffsetX = region.offsetX;
|
||||
attachment.regionOffsetY = region.offsetY;
|
||||
attachment.regionWidth = region.width;
|
||||
attachment.regionHeight = region.height;
|
||||
attachment.regionOriginalWidth = region.originalWidth;
|
||||
attachment.regionOriginalHeight = region.originalHeight;
|
||||
attachment.RegionOffsetX = region.offsetX;
|
||||
attachment.RegionOffsetY = region.offsetY;
|
||||
attachment.RegionWidth = region.width;
|
||||
attachment.RegionHeight = region.height;
|
||||
attachment.RegionOriginalWidth = region.originalWidth;
|
||||
attachment.RegionOriginalHeight = region.originalHeight;
|
||||
|
||||
if (updateOffset) attachment.UpdateOffset();
|
||||
}
|
||||
@ -74,12 +74,12 @@ namespace Spine.Unity.AttachmentTools {
|
||||
attachment.RegionU2 = region.u2;
|
||||
attachment.RegionV2 = region.v2;
|
||||
attachment.RegionDegrees = region.degrees;
|
||||
attachment.regionOffsetX = region.offsetX;
|
||||
attachment.regionOffsetY = region.offsetY;
|
||||
attachment.regionWidth = region.width;
|
||||
attachment.regionHeight = region.height;
|
||||
attachment.regionOriginalWidth = region.originalWidth;
|
||||
attachment.regionOriginalHeight = region.originalHeight;
|
||||
attachment.RegionOffsetX = region.offsetX;
|
||||
attachment.RegionOffsetY = region.offsetY;
|
||||
attachment.RegionWidth = region.width;
|
||||
attachment.RegionHeight = region.height;
|
||||
attachment.RegionOriginalWidth = region.originalWidth;
|
||||
attachment.RegionOriginalHeight = region.originalHeight;
|
||||
|
||||
if (updateUVs) attachment.UpdateUVs();
|
||||
}
|
||||
@ -130,26 +130,26 @@ namespace Spine.Unity.AttachmentTools {
|
||||
|
||||
attachment.RendererObject = region;
|
||||
attachment.SetUVs(region.u, region.v, region.u2, region.v2, region.degrees);
|
||||
attachment.regionOffsetX = region.offsetX;
|
||||
attachment.regionOffsetY = region.offsetY;
|
||||
attachment.regionWidth = region.width;
|
||||
attachment.regionHeight = region.height;
|
||||
attachment.regionOriginalWidth = region.originalWidth;
|
||||
attachment.regionOriginalHeight = region.originalHeight;
|
||||
attachment.RegionOffsetX = region.offsetX;
|
||||
attachment.RegionOffsetY = region.offsetY;
|
||||
attachment.RegionWidth = region.width;
|
||||
attachment.RegionHeight = region.height;
|
||||
attachment.RegionOriginalWidth = region.originalWidth;
|
||||
attachment.RegionOriginalHeight = region.originalHeight;
|
||||
|
||||
attachment.Path = region.name;
|
||||
attachment.scaleX = 1;
|
||||
attachment.scaleY = 1;
|
||||
attachment.rotation = rotation;
|
||||
attachment.ScaleX = 1;
|
||||
attachment.ScaleY = 1;
|
||||
attachment.Rotation = rotation;
|
||||
|
||||
attachment.r = 1;
|
||||
attachment.g = 1;
|
||||
attachment.b = 1;
|
||||
attachment.a = 1;
|
||||
attachment.R = 1;
|
||||
attachment.G = 1;
|
||||
attachment.B = 1;
|
||||
attachment.A = 1;
|
||||
|
||||
// pass OriginalWidth and OriginalHeight because UpdateOffset uses it in its calculation.
|
||||
attachment.width = attachment.regionOriginalWidth * scale;
|
||||
attachment.height = attachment.regionOriginalHeight * scale;
|
||||
attachment.Width = attachment.RegionOriginalWidth * scale;
|
||||
attachment.Height = attachment.RegionOriginalHeight * scale;
|
||||
|
||||
attachment.SetColor(Color.white);
|
||||
attachment.UpdateOffset();
|
||||
@ -158,31 +158,31 @@ namespace Spine.Unity.AttachmentTools {
|
||||
|
||||
/// <summary> Sets the scale. Call regionAttachment.UpdateOffset to apply the change.</summary>
|
||||
public static void SetScale (this RegionAttachment regionAttachment, Vector2 scale) {
|
||||
regionAttachment.scaleX = scale.x;
|
||||
regionAttachment.scaleY = scale.y;
|
||||
regionAttachment.ScaleX = scale.x;
|
||||
regionAttachment.ScaleY = scale.y;
|
||||
}
|
||||
|
||||
/// <summary> Sets the scale. Call regionAttachment.UpdateOffset to apply the change.</summary>
|
||||
public static void SetScale (this RegionAttachment regionAttachment, float x, float y) {
|
||||
regionAttachment.scaleX = x;
|
||||
regionAttachment.scaleY = y;
|
||||
regionAttachment.ScaleX = x;
|
||||
regionAttachment.ScaleY = y;
|
||||
}
|
||||
|
||||
/// <summary> Sets the position offset. Call regionAttachment.UpdateOffset to apply the change.</summary>
|
||||
public static void SetPositionOffset (this RegionAttachment regionAttachment, Vector2 offset) {
|
||||
regionAttachment.x = offset.x;
|
||||
regionAttachment.y = offset.y;
|
||||
regionAttachment.X = offset.x;
|
||||
regionAttachment.Y = offset.y;
|
||||
}
|
||||
|
||||
/// <summary> Sets the position offset. Call regionAttachment.UpdateOffset to apply the change.</summary>
|
||||
public static void SetPositionOffset (this RegionAttachment regionAttachment, float x, float y) {
|
||||
regionAttachment.x = x;
|
||||
regionAttachment.y = y;
|
||||
regionAttachment.X = x;
|
||||
regionAttachment.Y = y;
|
||||
}
|
||||
|
||||
/// <summary> Sets the rotation. Call regionAttachment.UpdateOffset to apply the change.</summary>
|
||||
public static void SetRotation (this RegionAttachment regionAttachment, float rotation) {
|
||||
regionAttachment.rotation = rotation;
|
||||
regionAttachment.Rotation = rotation;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -34,11 +34,11 @@ namespace Spine.Unity {
|
||||
|
||||
#region Colors
|
||||
const float ByteToFloat = 1f / 255f;
|
||||
public static Color GetColor (this Skeleton s) { return new Color(s.r, s.g, s.b, s.a); }
|
||||
public static Color GetColor (this RegionAttachment a) { return new Color(a.r, a.g, a.b, a.a); }
|
||||
public static Color GetColor (this MeshAttachment a) { return new Color(a.r, a.g, a.b, a.a); }
|
||||
public static Color GetColor (this Slot s) { return new Color(s.r, s.g, s.b, s.a); }
|
||||
public static Color GetColorTintBlack (this Slot s) { return new Color(s.r2, s.g2, s.b2, 1f); }
|
||||
public static Color GetColor (this Skeleton s) { return new Color(s.R, s.G, s.B, s.A); }
|
||||
public static Color GetColor (this RegionAttachment a) { return new Color(a.R, a.G, a.B, a.A); }
|
||||
public static Color GetColor (this MeshAttachment a) { return new Color(a.R, a.G, a.B, a.A); }
|
||||
public static Color GetColor (this Slot s) { return new Color(s.R, s.G, s.B, s.A); }
|
||||
public static Color GetColorTintBlack (this Slot s) { return new Color(s.R2, s.G2, s.B2, 1f); }
|
||||
|
||||
public static void SetColor (this Skeleton skeleton, Color color) {
|
||||
skeleton.A = color.a;
|
||||
@ -107,12 +107,12 @@ namespace Spine.Unity {
|
||||
/// <summary>Gets the internal bone matrix as a Unity bonespace-to-skeletonspace transformation matrix.</summary>
|
||||
public static Matrix4x4 GetMatrix4x4 (this Bone bone) {
|
||||
return new Matrix4x4 {
|
||||
m00 = bone.a,
|
||||
m01 = bone.b,
|
||||
m03 = bone.worldX,
|
||||
m10 = bone.c,
|
||||
m11 = bone.d,
|
||||
m13 = bone.worldY,
|
||||
m00 = bone.A,
|
||||
m01 = bone.B,
|
||||
m03 = bone.WorldX,
|
||||
m10 = bone.C,
|
||||
m11 = bone.D,
|
||||
m13 = bone.WorldY,
|
||||
m33 = 1
|
||||
};
|
||||
}
|
||||
@ -133,12 +133,12 @@ namespace Spine.Unity {
|
||||
|
||||
/// <summary>Gets the bone's local X and Y as a Vector2.</summary>
|
||||
public static Vector2 GetLocalPosition (this Bone bone) {
|
||||
return new Vector2(bone.x, bone.y);
|
||||
return new Vector2(bone.X, bone.Y);
|
||||
}
|
||||
|
||||
/// <summary>Gets the position of the bone in Skeleton-space.</summary>
|
||||
public static Vector2 GetSkeletonSpacePosition (this Bone bone) {
|
||||
return new Vector2(bone.worldX, bone.worldY);
|
||||
return new Vector2(bone.WorldX, bone.WorldY);
|
||||
}
|
||||
|
||||
/// <summary>Gets a local offset from the bone and converts it into Skeleton-space.</summary>
|
||||
@ -150,22 +150,22 @@ namespace Spine.Unity {
|
||||
|
||||
/// <summary>Gets the bone's Unity World position using its Spine GameObject Transform. UpdateWorldTransform needs to have been called for this to return the correct, updated value.</summary>
|
||||
public static Vector3 GetWorldPosition (this Bone bone, UnityEngine.Transform spineGameObjectTransform) {
|
||||
return spineGameObjectTransform.TransformPoint(new Vector3(bone.worldX, bone.worldY));
|
||||
return spineGameObjectTransform.TransformPoint(new Vector3(bone.WorldX, bone.WorldY));
|
||||
}
|
||||
|
||||
public static Vector3 GetWorldPosition (this Bone bone, UnityEngine.Transform spineGameObjectTransform, float positionScale) {
|
||||
return spineGameObjectTransform.TransformPoint(new Vector3(bone.worldX * positionScale, bone.worldY * positionScale));
|
||||
return spineGameObjectTransform.TransformPoint(new Vector3(bone.WorldX * positionScale, bone.WorldY * positionScale));
|
||||
}
|
||||
|
||||
/// <summary>Gets a skeleton space UnityEngine.Quaternion representation of bone.WorldRotationX.</summary>
|
||||
public static Quaternion GetQuaternion (this Bone bone) {
|
||||
var halfRotation = Mathf.Atan2(bone.c, bone.a) * 0.5f;
|
||||
var halfRotation = Mathf.Atan2(bone.C, bone.A) * 0.5f;
|
||||
return new Quaternion(0, 0, Mathf.Sin(halfRotation), Mathf.Cos(halfRotation));
|
||||
}
|
||||
|
||||
/// <summary>Gets a bone-local space UnityEngine.Quaternion representation of bone.rotation.</summary>
|
||||
public static Quaternion GetLocalQuaternion (this Bone bone) {
|
||||
var halfRotation = bone.rotation * Mathf.Deg2Rad * 0.5f;
|
||||
var halfRotation = bone.Rotation * Mathf.Deg2Rad * 0.5f;
|
||||
return new Quaternion(0, 0, Mathf.Sin(halfRotation), Mathf.Cos(halfRotation));
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ namespace Spine.Unity {
|
||||
|
||||
/// <summary>Calculates a 2x2 Transformation Matrix that can convert a skeleton-space position to a bone-local position.</summary>
|
||||
public static void GetWorldToLocalMatrix (this Bone bone, out float ia, out float ib, out float ic, out float id) {
|
||||
float a = bone.a, b = bone.b, c = bone.c, d = bone.d;
|
||||
float a = bone.A, b = bone.B, c = bone.C, d = bone.D;
|
||||
float invDet = 1 / (a * d - b * c);
|
||||
ia = invDet * d;
|
||||
ib = invDet * -b;
|
||||
@ -194,11 +194,11 @@ namespace Spine.Unity {
|
||||
/// <summary>Sets the skeleton-space position of a bone.</summary>
|
||||
/// <returns>The local position in its parent bone space, or in skeleton space if it is the root bone.</returns>
|
||||
public static Vector2 SetPositionSkeletonSpace (this Bone bone, Vector2 skeletonSpacePosition) {
|
||||
if (bone.parent == null) { // root bone
|
||||
if (bone.Parent == null) { // root bone
|
||||
bone.SetLocalPosition(skeletonSpacePosition);
|
||||
return skeletonSpacePosition;
|
||||
} else {
|
||||
var parent = bone.parent;
|
||||
var parent = bone.Parent;
|
||||
Vector2 parentLocal = parent.WorldToLocal(skeletonSpacePosition);
|
||||
bone.SetLocalPosition(parentLocal);
|
||||
return parentLocal;
|
||||
@ -228,13 +228,13 @@ namespace Spine.Unity {
|
||||
/// <param name="slot">Slot where the attachment belongs.</param>
|
||||
/// <param name="buffer">Correctly-sized buffer. Use attachment's .WorldVerticesLength to get the correct size. If null, a new Vector2[] of the correct size will be allocated.</param>
|
||||
public static Vector2[] GetLocalVertices (this VertexAttachment va, Slot slot, Vector2[] buffer) {
|
||||
int floatsCount = va.worldVerticesLength;
|
||||
int floatsCount = va.WorldVerticesLength;
|
||||
int bufferTargetSize = floatsCount >> 1;
|
||||
buffer = buffer ?? new Vector2[bufferTargetSize];
|
||||
if (buffer.Length < bufferTargetSize) throw new System.ArgumentException(string.Format("Vector2 buffer too small. {0} requires an array of size {1}. Use the attachment's .WorldVerticesLength to get the correct size.", va.Name, floatsCount), "buffer");
|
||||
|
||||
if (va.bones == null) {
|
||||
var localVerts = va.vertices;
|
||||
if (va.Bones == null) {
|
||||
var localVerts = va.Vertices;
|
||||
for (int i = 0; i < bufferTargetSize; i++) {
|
||||
int j = i * 2;
|
||||
buffer[i] = new Vector2(localVerts[j], localVerts[j + 1]);
|
||||
@ -243,8 +243,8 @@ namespace Spine.Unity {
|
||||
var floats = new float[floatsCount];
|
||||
va.ComputeWorldVertices(slot, floats);
|
||||
|
||||
Bone sb = slot.bone;
|
||||
float ia, ib, ic, id, bwx = sb.worldX, bwy = sb.worldY;
|
||||
Bone sb = slot.Bone;
|
||||
float ia, ib, ic, id, bwx = sb.WorldX, bwy = sb.WorldY;
|
||||
sb.GetWorldToLocalMatrix(out ia, out ib, out ic, out id);
|
||||
|
||||
for (int i = 0; i < bufferTargetSize; i++) {
|
||||
@ -262,7 +262,7 @@ namespace Spine.Unity {
|
||||
/// <param name="slot">Slot where the attachment belongs.</param>
|
||||
/// <param name="buffer">Correctly-sized buffer. Use attachment's .WorldVerticesLength to get the correct size. If null, a new Vector2[] of the correct size will be allocated.</param>
|
||||
public static Vector2[] GetWorldVertices (this VertexAttachment a, Slot slot, Vector2[] buffer) {
|
||||
int worldVertsLength = a.worldVerticesLength;
|
||||
int worldVertsLength = a.WorldVerticesLength;
|
||||
int bufferTargetSize = worldVertsLength >> 1;
|
||||
buffer = buffer ?? new Vector2[bufferTargetSize];
|
||||
if (buffer.Length < bufferTargetSize) throw new System.ArgumentException(string.Format("Vector2 buffer too small. {0} requires an array of size {1}. Use the attachment's .WorldVerticesLength to get the correct size.", a.Name, worldVertsLength), "buffer");
|
||||
@ -282,7 +282,7 @@ namespace Spine.Unity {
|
||||
public static Vector3 GetWorldPosition (this PointAttachment attachment, Slot slot, Transform spineGameObjectTransform) {
|
||||
Vector3 skeletonSpacePosition;
|
||||
skeletonSpacePosition.z = 0;
|
||||
attachment.ComputeWorldPosition(slot.bone, out skeletonSpacePosition.x, out skeletonSpacePosition.y);
|
||||
attachment.ComputeWorldPosition(slot.Bone, out skeletonSpacePosition.x, out skeletonSpacePosition.y);
|
||||
return spineGameObjectTransform.TransformPoint(skeletonSpacePosition);
|
||||
}
|
||||
|
||||
@ -310,29 +310,29 @@ namespace Spine {
|
||||
return default(BoneMatrix);
|
||||
|
||||
// End condition: isRootBone
|
||||
if (boneData.parent == null)
|
||||
if (boneData.Parent == null)
|
||||
return GetInheritedInternal(boneData, default(BoneMatrix));
|
||||
|
||||
BoneMatrix result = CalculateSetupWorld(boneData.parent);
|
||||
BoneMatrix result = CalculateSetupWorld(boneData.Parent);
|
||||
return GetInheritedInternal(boneData, result);
|
||||
}
|
||||
|
||||
static BoneMatrix GetInheritedInternal (BoneData boneData, BoneMatrix parentMatrix) {
|
||||
var parent = boneData.parent;
|
||||
var parent = boneData.Parent;
|
||||
if (parent == null) return new BoneMatrix(boneData); // isRootBone
|
||||
|
||||
float pa = parentMatrix.a, pb = parentMatrix.b, pc = parentMatrix.c, pd = parentMatrix.d;
|
||||
BoneMatrix result = default(BoneMatrix);
|
||||
result.x = pa * boneData.x + pb * boneData.y + parentMatrix.x;
|
||||
result.y = pc * boneData.x + pd * boneData.y + parentMatrix.y;
|
||||
result.x = pa * boneData.X + pb * boneData.Y + parentMatrix.x;
|
||||
result.y = pc * boneData.X + pd * boneData.Y + parentMatrix.y;
|
||||
|
||||
switch (boneData.transformMode) {
|
||||
switch (boneData.TransformMode) {
|
||||
case TransformMode.Normal: {
|
||||
float rotationY = boneData.rotation + 90 + boneData.shearY;
|
||||
float la = MathUtils.CosDeg(boneData.rotation + boneData.shearX) * boneData.scaleX;
|
||||
float lb = MathUtils.CosDeg(rotationY) * boneData.scaleY;
|
||||
float lc = MathUtils.SinDeg(boneData.rotation + boneData.shearX) * boneData.scaleX;
|
||||
float ld = MathUtils.SinDeg(rotationY) * boneData.scaleY;
|
||||
float rotationY = boneData.Rotation + 90 + boneData.ShearY;
|
||||
float la = MathUtils.CosDeg(boneData.Rotation + boneData.ShearX) * boneData.ScaleX;
|
||||
float lb = MathUtils.CosDeg(rotationY) * boneData.ScaleY;
|
||||
float lc = MathUtils.SinDeg(boneData.Rotation + boneData.ShearX) * boneData.ScaleX;
|
||||
float ld = MathUtils.SinDeg(rotationY) * boneData.ScaleY;
|
||||
result.a = pa * la + pb * lc;
|
||||
result.b = pa * lb + pb * ld;
|
||||
result.c = pc * la + pd * lc;
|
||||
@ -340,11 +340,11 @@ namespace Spine {
|
||||
break;
|
||||
}
|
||||
case TransformMode.OnlyTranslation: {
|
||||
float rotationY = boneData.rotation + 90 + boneData.shearY;
|
||||
result.a = MathUtils.CosDeg(boneData.rotation + boneData.shearX) * boneData.scaleX;
|
||||
result.b = MathUtils.CosDeg(rotationY) * boneData.scaleY;
|
||||
result.c = MathUtils.SinDeg(boneData.rotation + boneData.shearX) * boneData.scaleX;
|
||||
result.d = MathUtils.SinDeg(rotationY) * boneData.scaleY;
|
||||
float rotationY = boneData.Rotation + 90 + boneData.ShearY;
|
||||
result.a = MathUtils.CosDeg(boneData.Rotation + boneData.ShearX) * boneData.ScaleX;
|
||||
result.b = MathUtils.CosDeg(rotationY) * boneData.ScaleY;
|
||||
result.c = MathUtils.SinDeg(boneData.Rotation + boneData.ShearX) * boneData.ScaleX;
|
||||
result.d = MathUtils.SinDeg(rotationY) * boneData.ScaleY;
|
||||
break;
|
||||
}
|
||||
case TransformMode.NoRotationOrReflection: {
|
||||
@ -359,12 +359,12 @@ namespace Spine {
|
||||
pc = 0;
|
||||
prx = 90 - MathUtils.Atan2(pd, pb) * MathUtils.RadDeg;
|
||||
}
|
||||
float rx = boneData.rotation + boneData.shearX - prx;
|
||||
float ry = boneData.rotation + boneData.shearY - prx + 90;
|
||||
float la = MathUtils.CosDeg(rx) * boneData.scaleX;
|
||||
float lb = MathUtils.CosDeg(ry) * boneData.scaleY;
|
||||
float lc = MathUtils.SinDeg(rx) * boneData.scaleX;
|
||||
float ld = MathUtils.SinDeg(ry) * boneData.scaleY;
|
||||
float rx = boneData.Rotation + boneData.ShearX - prx;
|
||||
float ry = boneData.Rotation + boneData.ShearY - prx + 90;
|
||||
float la = MathUtils.CosDeg(rx) * boneData.ScaleX;
|
||||
float lb = MathUtils.CosDeg(ry) * boneData.ScaleY;
|
||||
float lc = MathUtils.SinDeg(rx) * boneData.ScaleX;
|
||||
float ld = MathUtils.SinDeg(ry) * boneData.ScaleY;
|
||||
result.a = pa * la - pb * lc;
|
||||
result.b = pa * lb - pb * ld;
|
||||
result.c = pc * la + pd * lc;
|
||||
@ -373,7 +373,7 @@ namespace Spine {
|
||||
}
|
||||
case TransformMode.NoScale:
|
||||
case TransformMode.NoScaleOrReflection: {
|
||||
float cos = MathUtils.CosDeg(boneData.rotation), sin = MathUtils.SinDeg(boneData.rotation);
|
||||
float cos = MathUtils.CosDeg(boneData.Rotation), sin = MathUtils.SinDeg(boneData.Rotation);
|
||||
float za = pa * cos + pb * sin;
|
||||
float zc = pc * cos + pd * sin;
|
||||
float s = (float)Math.Sqrt(za * za + zc * zc);
|
||||
@ -385,11 +385,11 @@ namespace Spine {
|
||||
float r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za);
|
||||
float zb = MathUtils.Cos(r) * s;
|
||||
float zd = MathUtils.Sin(r) * s;
|
||||
float la = MathUtils.CosDeg(boneData.shearX) * boneData.scaleX;
|
||||
float lb = MathUtils.CosDeg(90 + boneData.shearY) * boneData.scaleY;
|
||||
float lc = MathUtils.SinDeg(boneData.shearX) * boneData.scaleX;
|
||||
float ld = MathUtils.SinDeg(90 + boneData.shearY) * boneData.scaleY;
|
||||
if (boneData.transformMode != TransformMode.NoScaleOrReflection ? pa * pd - pb * pc < 0 : false) {
|
||||
float la = MathUtils.CosDeg(boneData.ShearX) * boneData.ScaleX;
|
||||
float lb = MathUtils.CosDeg(90 + boneData.ShearY) * boneData.ScaleY;
|
||||
float lc = MathUtils.SinDeg(boneData.ShearX) * boneData.ScaleX;
|
||||
float ld = MathUtils.SinDeg(90 + boneData.ShearY) * boneData.ScaleY;
|
||||
if (boneData.TransformMode != TransformMode.NoScaleOrReflection ? pa * pd - pb * pc < 0 : false) {
|
||||
zb = -zb;
|
||||
zd = -zd;
|
||||
}
|
||||
@ -406,28 +406,28 @@ namespace Spine {
|
||||
|
||||
/// <summary>Constructor for a local bone matrix based on Setup Pose BoneData.</summary>
|
||||
public BoneMatrix (BoneData boneData) {
|
||||
float rotationY = boneData.rotation + 90 + boneData.shearY;
|
||||
float rotationX = boneData.rotation + boneData.shearX;
|
||||
float rotationY = boneData.Rotation + 90 + boneData.ShearY;
|
||||
float rotationX = boneData.Rotation + boneData.ShearX;
|
||||
|
||||
a = MathUtils.CosDeg(rotationX) * boneData.scaleX;
|
||||
c = MathUtils.SinDeg(rotationX) * boneData.scaleX;
|
||||
b = MathUtils.CosDeg(rotationY) * boneData.scaleY;
|
||||
d = MathUtils.SinDeg(rotationY) * boneData.scaleY;
|
||||
x = boneData.x;
|
||||
y = boneData.y;
|
||||
a = MathUtils.CosDeg(rotationX) * boneData.ScaleX;
|
||||
c = MathUtils.SinDeg(rotationX) * boneData.ScaleX;
|
||||
b = MathUtils.CosDeg(rotationY) * boneData.ScaleY;
|
||||
d = MathUtils.SinDeg(rotationY) * boneData.ScaleY;
|
||||
x = boneData.X;
|
||||
y = boneData.Y;
|
||||
}
|
||||
|
||||
/// <summary>Constructor for a local bone matrix based on a bone instance's current pose.</summary>
|
||||
public BoneMatrix (Bone bone) {
|
||||
float rotationY = bone.rotation + 90 + bone.shearY;
|
||||
float rotationX = bone.rotation + bone.shearX;
|
||||
float rotationY = bone.Rotation + 90 + bone.ShearY;
|
||||
float rotationX = bone.Rotation + bone.ShearX;
|
||||
|
||||
a = MathUtils.CosDeg(rotationX) * bone.scaleX;
|
||||
c = MathUtils.SinDeg(rotationX) * bone.scaleX;
|
||||
b = MathUtils.CosDeg(rotationY) * bone.scaleY;
|
||||
d = MathUtils.SinDeg(rotationY) * bone.scaleY;
|
||||
x = bone.x;
|
||||
y = bone.y;
|
||||
a = MathUtils.CosDeg(rotationX) * bone.ScaleX;
|
||||
c = MathUtils.SinDeg(rotationX) * bone.ScaleX;
|
||||
b = MathUtils.CosDeg(rotationY) * bone.ScaleY;
|
||||
d = MathUtils.SinDeg(rotationY) * bone.ScaleY;
|
||||
x = bone.X;
|
||||
y = bone.Y;
|
||||
}
|
||||
|
||||
public BoneMatrix TransformMatrix (BoneMatrix local) {
|
||||
@ -444,7 +444,7 @@ namespace Spine {
|
||||
|
||||
public static class SpineSkeletonExtensions {
|
||||
public static bool IsWeighted (this VertexAttachment va) {
|
||||
return va.bones != null && va.bones.Length > 0;
|
||||
return va.Bones != null && va.Bones.Length > 0;
|
||||
}
|
||||
|
||||
#region Transform Modes
|
||||
@ -458,13 +458,5 @@ namespace Spine {
|
||||
return ((int)mode & (1U << ScaleBit)) == 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
// Note: This extension method is required by SpineAnimationStateMixerBehaviour,
|
||||
// which is part of the timeline extension package. Thus the internal member variable
|
||||
// nextTrackLast is not accessible. We favor providing this extension method
|
||||
// over exposing nextTrackLast as public property, which would rather confuse users.
|
||||
public static void AllowImmediateQueue (this TrackEntry trackEntry) {
|
||||
if (trackEntry.nextTrackLast < 0) trackEntry.nextTrackLast = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,39 +36,12 @@ namespace Spine.Unity.AnimationTools {
|
||||
|
||||
/// <summary>Evaluates the resulting value of a TranslateTimeline at a given time.
|
||||
/// SkeletonData can be accessed from Skeleton.Data or from SkeletonDataAsset.GetSkeletonData.
|
||||
/// If no SkeletonData is given, values are computed relative to setup pose instead of local-absolute.</summary>
|
||||
/// If no SkeletonData is given, values are returned as difference to setup pose
|
||||
/// instead of absolute values.</summary>
|
||||
public static Vector2 Evaluate (this TranslateTimeline timeline, float time, SkeletonData skeletonData = null) {
|
||||
var frames = timeline.frames;
|
||||
if (time < frames[0]) return Vector2.zero;
|
||||
|
||||
float x, y;
|
||||
int i = TranslateTimeline.Search(frames, time, TranslateTimeline.ENTRIES), curveType = (int)timeline.curves[i / TranslateTimeline.ENTRIES];
|
||||
switch (curveType) {
|
||||
case TranslateTimeline.LINEAR:
|
||||
float before = frames[i];
|
||||
x = frames[i + TranslateTimeline.VALUE1];
|
||||
y = frames[i + TranslateTimeline.VALUE2];
|
||||
float t = (time - before) / (frames[i + TranslateTimeline.ENTRIES] - before);
|
||||
x += (frames[i + TranslateTimeline.ENTRIES + TranslateTimeline.VALUE1] - x) * t;
|
||||
y += (frames[i + TranslateTimeline.ENTRIES + TranslateTimeline.VALUE2] - y) * t;
|
||||
break;
|
||||
case TranslateTimeline.STEPPED:
|
||||
x = frames[i + TranslateTimeline.VALUE1];
|
||||
y = frames[i + TranslateTimeline.VALUE2];
|
||||
break;
|
||||
default:
|
||||
x = timeline.GetBezierValue(time, i, TranslateTimeline.VALUE1, curveType - TranslateTimeline.BEZIER);
|
||||
y = timeline.GetBezierValue(time, i, TranslateTimeline.VALUE2, curveType + TranslateTimeline.BEZIER_SIZE - TranslateTimeline.BEZIER);
|
||||
break;
|
||||
}
|
||||
|
||||
Vector2 xy = new Vector2(x, y);
|
||||
if (skeletonData == null) {
|
||||
return xy;
|
||||
} else {
|
||||
var boneData = skeletonData.bones.Items[timeline.BoneIndex];
|
||||
return xy + new Vector2(boneData.x, boneData.y);
|
||||
}
|
||||
timeline.Evaluate(out x, out y, time, skeletonData);
|
||||
return new Vector2(x, y);
|
||||
}
|
||||
|
||||
/// <summary>Gets the translate timeline for a given boneIndex.
|
||||
@ -76,7 +49,7 @@ namespace Spine.Unity.AnimationTools {
|
||||
/// The root bone is always boneIndex 0.
|
||||
/// This will return null if a TranslateTimeline is not found.</summary>
|
||||
public static TranslateTimeline FindTranslateTimelineForBone (this Animation a, int boneIndex) {
|
||||
foreach (var timeline in a.timelines) {
|
||||
foreach (var timeline in a.Timelines) {
|
||||
if (timeline.GetType().IsSubclassOf(typeof(TranslateTimeline)))
|
||||
continue;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "com.esotericsoftware.spine.spine-unity",
|
||||
"displayName": "spine-unity Runtime",
|
||||
"description": "This plugin provides the spine-unity runtime core.",
|
||||
"version": "3.9.0",
|
||||
"version": "4.0.0",
|
||||
"unity": "2018.3",
|
||||
"author": {
|
||||
"name": "Esoteric Software",
|
||||
@ -10,10 +10,23 @@
|
||||
"url": "http://esotericsoftware.com/"
|
||||
},
|
||||
"dependencies": {
|
||||
"com.esotericsoftware.spine.spine-csharp": "4.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:EsotericSoftware/spine-runtimes.git"
|
||||
},
|
||||
"keywords": [
|
||||
"spine",
|
||||
"spine-unity",
|
||||
"core"
|
||||
]
|
||||
"runtimes",
|
||||
"2d",
|
||||
"skeletal",
|
||||
"animation"
|
||||
],
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"bugs": {
|
||||
"url": "https://github.com/EsotericSoftware/spine-runtimes/issues"
|
||||
},
|
||||
"homepage": "https://github.com/EsotericSoftware/spine-runtimes#readme"
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
"name": "spine-timeline",
|
||||
"references": [
|
||||
"spine-unity",
|
||||
"spine-csharp",
|
||||
"Unity.Timeline"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
"url": "http://esotericsoftware.com/"
|
||||
},
|
||||
"dependencies": {
|
||||
"com.unity.timeline": "1.2.10"
|
||||
"com.unity.timeline": "1.2.10",
|
||||
"com.esotericsoftware.spine.spine-unity": "4.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"spine",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user