mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-07 03:06:55 +08:00
[unity] Changed skeleton flipX/Y to scaleX/Y.
This commit is contained in:
parent
0f7c01c469
commit
d336712ccc
@ -229,9 +229,9 @@ namespace Spine.Unity.Editor {
|
|||||||
|
|
||||||
// Flip
|
// Flip
|
||||||
EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(160f));
|
EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(160f));
|
||||||
EditorGUILayout.LabelField("Flip", GUILayout.MaxWidth(EditorGUIUtility.labelWidth - 20f));
|
EditorGUILayout.LabelField("Scale", GUILayout.MaxWidth(EditorGUIUtility.labelWidth - 20f));
|
||||||
skeleton.FlipX = EditorGUILayout.ToggleLeft(".FlipX", skeleton.FlipX, GUILayout.MaxWidth(70f));
|
skeleton.ScaleX = EditorGUILayout.DelayedFloatField(".ScaleX", skeleton.ScaleX, GUILayout.MaxWidth(70f));
|
||||||
skeleton.FlipY = EditorGUILayout.ToggleLeft(".FlipY", skeleton.FlipY, GUILayout.MaxWidth(70f));
|
skeleton.ScaleY = EditorGUILayout.DelayedFloatField(".ScaleY", skeleton.ScaleY, GUILayout.MaxWidth(70f));
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
|
|||||||
@ -164,19 +164,14 @@ namespace Spine.Unity {
|
|||||||
if (followBoneRotation) {
|
if (followBoneRotation) {
|
||||||
Vector3 worldRotation = skeletonTransform.rotation.eulerAngles;
|
Vector3 worldRotation = skeletonTransform.rotation.eulerAngles;
|
||||||
if (followLocalScale && bone.scaleX < 0) boneWorldRotation += 180f;
|
if (followLocalScale && bone.scaleX < 0) boneWorldRotation += 180f;
|
||||||
#if UNITY_5_6_OR_NEWER
|
|
||||||
thisTransform.SetPositionAndRotation(targetWorldPosition, Quaternion.Euler(worldRotation.x, worldRotation.y, worldRotation.z + boneWorldRotation));
|
thisTransform.SetPositionAndRotation(targetWorldPosition, Quaternion.Euler(worldRotation.x, worldRotation.y, worldRotation.z + boneWorldRotation));
|
||||||
#else
|
|
||||||
thisTransform.position = targetWorldPosition;
|
|
||||||
thisTransform.rotation = Quaternion.Euler(worldRotation.x, worldRotation.y, worldRotation.z + bone.WorldRotationX);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
thisTransform.position = targetWorldPosition;
|
thisTransform.position = targetWorldPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 *= bone.skeleton.flipX ^ bone.skeleton.flipY ? -1f : 1f;
|
if (followSkeletonFlip) localScale.y *= Mathf.Sign(bone.skeleton.scaleX * bone.skeleton.scaleY);
|
||||||
thisTransform.localScale = localScale;
|
thisTransform.localScale = localScale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,7 +145,7 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
if (followSkeletonFlip) {
|
if (followSkeletonFlip) {
|
||||||
Vector3 localScale = thisTransform.localScale;
|
Vector3 localScale = thisTransform.localScale;
|
||||||
localScale.y = Mathf.Abs(localScale.y) * (bone.skeleton.flipX ^ bone.skeleton.flipY ? -1f : 1f);
|
localScale.y = Mathf.Abs(localScale.y) * Mathf.Sign(bone.skeleton.scaleX * bone.skeleton.scaleY);
|
||||||
thisTransform.localScale = localScale;
|
thisTransform.localScale = localScale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -207,8 +207,8 @@ namespace Spine.Unity {
|
|||||||
rendererBuffers.Initialize();
|
rendererBuffers.Initialize();
|
||||||
|
|
||||||
skeleton = new Skeleton(skeletonData) {
|
skeleton = new Skeleton(skeletonData) {
|
||||||
flipX = initialFlipX,
|
scaleX = initialFlipX ? -1 : 1,
|
||||||
flipY = initialFlipY
|
scaleY = initialFlipY ? -1 : 1
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(initialSkinName) && !string.Equals(initialSkinName, "default", System.StringComparison.Ordinal))
|
if (!string.IsNullOrEmpty(initialSkinName) && !string.Equals(initialSkinName, "default", System.StringComparison.Ordinal))
|
||||||
|
|||||||
@ -308,10 +308,10 @@ namespace Spine.Unity {
|
|||||||
#if SPINE_TRIANGLECHECK
|
#if SPINE_TRIANGLECHECK
|
||||||
var clippingAttachment = attachment as ClippingAttachment;
|
var clippingAttachment = attachment as ClippingAttachment;
|
||||||
if (clippingAttachment != null) {
|
if (clippingAttachment != null) {
|
||||||
clippingEndSlot = clippingAttachment.endSlot;
|
clippingEndSlot = clippingAttachment.endSlot;
|
||||||
clippingAttachmentSource = i;
|
clippingAttachmentSource = i;
|
||||||
current.hasClipping = true;
|
current.hasClipping = true;
|
||||||
skeletonHasClipping = true;
|
skeletonHasClipping = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
noRender = true;
|
noRender = true;
|
||||||
|
|||||||
@ -313,8 +313,8 @@ namespace Spine.Unity.Modules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdateSpineSkeleton (ISkeletonAnimation skeletonRenderer) {
|
void UpdateSpineSkeleton (ISkeletonAnimation skeletonRenderer) {
|
||||||
bool flipX = skeleton.flipX;
|
bool flipX = skeleton.ScaleX < 0;
|
||||||
bool flipY = skeleton.flipY;
|
bool flipY = skeleton.ScaleY < 0;
|
||||||
bool flipXOR = flipX ^ flipY;
|
bool flipXOR = flipX ^ flipY;
|
||||||
bool flipOR = flipX || flipY;
|
bool flipOR = flipX || flipY;
|
||||||
|
|
||||||
|
|||||||
@ -311,8 +311,8 @@ namespace Spine.Unity.Modules {
|
|||||||
|
|
||||||
/// <summary>Performed every skeleton animation update to translate Unity Transforms positions into Spine bone transforms.</summary>
|
/// <summary>Performed every skeleton animation update to translate Unity Transforms positions into Spine bone transforms.</summary>
|
||||||
void UpdateSpineSkeleton (ISkeletonAnimation animatedSkeleton) {
|
void UpdateSpineSkeleton (ISkeletonAnimation animatedSkeleton) {
|
||||||
bool flipX = skeleton.flipX;
|
bool flipX = skeleton.ScaleX < 0;
|
||||||
bool flipY = skeleton.flipY;
|
bool flipY = skeleton.ScaleY < 0;
|
||||||
bool flipXOR = flipX ^ flipY;
|
bool flipXOR = flipX ^ flipY;
|
||||||
bool flipOR = flipX || flipY;
|
bool flipOR = flipX || flipY;
|
||||||
var startingBone = this.StartingBone;
|
var startingBone = this.StartingBone;
|
||||||
|
|||||||
@ -123,7 +123,7 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 *= bone.skeleton.flipX ^ bone.skeleton.flipY ? -1f : 1f;
|
if (followSkeletonFlip) localScale.y *= Mathf.Sign(bone.skeleton.scaleX * bone.skeleton.scaleY);
|
||||||
thisTransform.localScale = localScale;
|
thisTransform.localScale = localScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -82,8 +82,8 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
// Only provide visual feedback to inspector changes in Unity Editor Edit mode.
|
// Only provide visual feedback to inspector changes in Unity Editor Edit mode.
|
||||||
if (!Application.isPlaying) {
|
if (!Application.isPlaying) {
|
||||||
skeleton.flipX = this.initialFlipX;
|
skeleton.scaleX = this.initialFlipX ? -1 : 1;
|
||||||
skeleton.flipY = this.initialFlipY;
|
skeleton.scaleY = this.initialFlipY ? -1 : 1;
|
||||||
|
|
||||||
skeleton.SetToSetupPose();
|
skeleton.SetToSetupPose();
|
||||||
if (!string.IsNullOrEmpty(startingAnimation))
|
if (!string.IsNullOrEmpty(startingAnimation))
|
||||||
@ -233,8 +233,8 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.skeleton = new Skeleton(skeletonData) {
|
this.skeleton = new Skeleton(skeletonData) {
|
||||||
flipX = this.initialFlipX,
|
scaleX = this.initialFlipX ? -1 : 1,
|
||||||
flipY = this.initialFlipY
|
scaleY = this.initialFlipY ? -1 : 1
|
||||||
};
|
};
|
||||||
|
|
||||||
meshBuffers = new DoubleBuffered<MeshRendererBuffers.SmartMesh>();
|
meshBuffers = new DoubleBuffered<MeshRendererBuffers.SmartMesh>();
|
||||||
|
|||||||
@ -123,10 +123,10 @@ namespace Spine.Unity {
|
|||||||
var skeleton = skeletonRenderer.skeleton;
|
var skeleton = skeletonRenderer.skeleton;
|
||||||
if (boneRoot != null && skeleton != null) {
|
if (boneRoot != null && skeleton != null) {
|
||||||
Vector3 flipScale = Vector3.one;
|
Vector3 flipScale = Vector3.one;
|
||||||
if (skeleton.FlipX)
|
if (skeleton.scaleX < 0)
|
||||||
flipScale.x = -1;
|
flipScale.x = -1;
|
||||||
|
|
||||||
if (skeleton.FlipY)
|
if (skeleton.scaleY < 0)
|
||||||
flipScale.y = -1;
|
flipScale.y = -1;
|
||||||
|
|
||||||
boneRoot.localScale = flipScale;
|
boneRoot.localScale = flipScale;
|
||||||
|
|||||||
@ -119,7 +119,7 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var thisTransform = cachedTransform;
|
var thisTransform = cachedTransform;
|
||||||
float skeletonFlipRotation = (skeleton.flipX ^ skeleton.flipY) ? -1f : 1f;
|
float skeletonFlipRotation = Mathf.Sign(skeleton.scaleX * skeleton.scaleY);
|
||||||
if (mode == Mode.Follow) {
|
if (mode == Mode.Follow) {
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case UpdatePhase.Local:
|
case UpdatePhase.Local:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user