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