diff --git a/spine-csharp/src/Bone.cs b/spine-csharp/src/Bone.cs index d6d9662cd..b48b1a45c 100644 --- a/spine-csharp/src/Bone.cs +++ b/spine-csharp/src/Bone.cs @@ -150,7 +150,7 @@ namespace Spine { Bone parent = this.parent; if (parent == null) { // Root bone. - float rotationY = rotation + 90 + shearY, sx = skeleton.scaleX, sy = skeleton.scaleY; + float rotationY = rotation + 90 + shearY, sx = skeleton.ScaleX, sy = skeleton.ScaleY; a = MathUtils.CosDeg(rotation + shearX) * scaleX * sx; b = MathUtils.CosDeg(rotationY) * scaleY * sx; c = MathUtils.SinDeg(rotation + shearX) * scaleX * sy; @@ -212,15 +212,15 @@ namespace Spine { case TransformMode.NoScale: case TransformMode.NoScaleOrReflection: { float cos = MathUtils.CosDeg(rotation), sin = MathUtils.SinDeg(rotation); - float za = (pa * cos + pb * sin) / skeleton.scaleX; - float zc = (pc * cos + pd * sin) / skeleton.scaleY; + float za = (pa * cos + pb * sin) / skeleton.ScaleX; + float zc = (pc * cos + pd * sin) / skeleton.ScaleY; float s = (float)Math.Sqrt(za * za + zc * zc); if (s > 0.00001f) s = 1 / s; za *= s; zc *= s; s = (float)Math.Sqrt(za * za + zc * zc); if (data.transformMode == TransformMode.NoScale - && (pa * pd - pb * pc < 0) != (skeleton.scaleX < 0 != skeleton.scaleY < 0)) s = -s; + && (pa * pd - pb * pc < 0) != (skeleton.ScaleX < 0 != skeleton.ScaleY < 0)) s = -s; float r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za); float zb = MathUtils.Cos(r) * s; @@ -237,10 +237,10 @@ namespace Spine { } } - a *= skeleton.scaleX; - b *= skeleton.scaleX; - c *= skeleton.scaleY; - d *= skeleton.scaleY; + a *= skeleton.ScaleX; + b *= skeleton.ScaleX; + c *= skeleton.ScaleY; + d *= skeleton.ScaleY; } public void SetToSetupPose () { diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs index 47ae149dd..107a4e98a 100644 --- a/spine-csharp/src/Skeleton.cs +++ b/spine-csharp/src/Skeleton.cs @@ -44,7 +44,7 @@ namespace Spine { internal Skin skin; internal float r = 1, g = 1, b = 1, a = 1; internal float time; - internal float scaleX = 1, scaleY = 1; + private float scaleX = 1, scaleY = 1; internal float x, y; public SkeletonData Data { get { return data; } } @@ -64,7 +64,7 @@ namespace Spine { public float X { get { return x; } set { x = value; } } public float Y { get { return y; } set { y = value; } } public float ScaleX { get { return scaleX; } set { scaleX = value; } } - public float ScaleY { get { return scaleY; } set { scaleY = value; } } + public float ScaleY { get { return scaleY * (Bone.yDown ? -1 : 1); } set { scaleY = value; } } [Obsolete("Use ScaleX instead. FlipX is when ScaleX is negative.")] public bool FlipX { get { return scaleX < 0; } set { scaleX = value ? -1f : 1f; } } diff --git a/spine-monogame/example/ExampleGame.cs b/spine-monogame/example/ExampleGame.cs index 637940bc6..2651dbbb4 100644 --- a/spine-monogame/example/ExampleGame.cs +++ b/spine-monogame/example/ExampleGame.cs @@ -77,8 +77,7 @@ namespace Spine { AnimationStateData stateData = new AnimationStateData(skeleton.Data); state = new AnimationState(stateData); - // Flip the skeleton on the y-axis and center it within the viewport - skeleton.ScaleY = -1; + // Center within the viewport skeleton.X = game.GraphicsDevice.Viewport.Width / 2; skeleton.Y = game.GraphicsDevice.Viewport.Height; @@ -135,7 +134,6 @@ namespace Spine { AnimationStateData stateData = new AnimationStateData(skeleton.Data); state = new AnimationState(stateData); - skeleton.ScaleY = -1; skeleton.X = game.GraphicsDevice.Viewport.Width / 2 + 200; skeleton.Y = game.GraphicsDevice.Viewport.Height; @@ -182,7 +180,6 @@ namespace Spine { AnimationStateData stateData = new AnimationStateData(skeleton.Data); state = new AnimationState(stateData); - skeleton.ScaleY = -1; skeleton.X = game.GraphicsDevice.Viewport.Width / 2; skeleton.Y = game.GraphicsDevice.Viewport.Height; @@ -237,7 +234,6 @@ namespace Spine { AnimationStateData stateData = new AnimationStateData(skeleton.Data); state = new AnimationState(stateData); - skeleton.ScaleY = -1; skeleton.X = game.GraphicsDevice.Viewport.Width / 2; skeleton.Y = game.GraphicsDevice.Viewport.Height; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/BoneFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/BoneFollower.cs index 122c8f3ed..2723662d7 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/BoneFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/BoneFollower.cs @@ -177,7 +177,7 @@ namespace Spine.Unity { } 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); + if (followSkeletonFlip) localScale.y *= Mathf.Sign(bone.skeleton.ScaleX * bone.skeleton.ScaleY); thisTransform.localScale = localScale; } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/PointFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/PointFollower.cs index 1808c4773..ca68a72a2 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/PointFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/PointFollower.cs @@ -150,7 +150,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; } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs index cc3d934aa..872e42e4a 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs @@ -291,8 +291,8 @@ namespace Spine.Unity { rendererBuffers.Initialize(); skeleton = new Skeleton(skeletonData) { - scaleX = initialFlipX ? -1 : 1, - scaleY = initialFlipY ? -1 : 1 + ScaleX = initialFlipX ? -1 : 1, + ScaleY = initialFlipY ? -1 : 1 }; if (!string.IsNullOrEmpty(initialSkinName) && !string.Equals(initialSkinName, "default", System.StringComparison.Ordinal)) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/BoneFollowerGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/BoneFollowerGraphic.cs index 47bdd4548..76077bcf1 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/BoneFollowerGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/BoneFollowerGraphic.cs @@ -159,7 +159,7 @@ namespace Spine.Unity { } 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); + if (followSkeletonFlip) localScale.y *= Mathf.Sign(bone.skeleton.ScaleX * bone.skeleton.ScaleY); thisTransform.localScale = localScale; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs index a4afb30a3..b6ec6e603 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs @@ -89,8 +89,8 @@ namespace Spine.Unity { // Only provide visual feedback to inspector changes in Unity Editor Edit mode. if (!Application.isPlaying) { - skeleton.scaleX = this.initialFlipX ? -1 : 1; - skeleton.scaleY = this.initialFlipY ? -1 : 1; + skeleton.ScaleX = this.initialFlipX ? -1 : 1; + skeleton.ScaleY = this.initialFlipY ? -1 : 1; state.ClearTrack(0); skeleton.SetToSetupPose(); @@ -267,8 +267,8 @@ namespace Spine.Unity { } this.skeleton = new Skeleton(skeletonData) { - scaleX = this.initialFlipX ? -1 : 1, - scaleY = this.initialFlipY ? -1 : 1 + ScaleX = this.initialFlipX ? -1 : 1, + ScaleY = this.initialFlipY ? -1 : 1 }; meshBuffers = new DoubleBuffered(); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Timeline/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Timeline/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs index 33e42f3b4..615579be6 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Timeline/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Timeline/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs @@ -82,14 +82,14 @@ namespace Spine.Unity.Playables { } if (currentInputs != 1 && 1f - totalWeight > greatestWeight) { - skeleton.scaleX = originalScaleX; - skeleton.scaleY = originalScaleY; + skeleton.ScaleX = originalScaleX; + skeleton.ScaleY = originalScaleY; } } public void SetSkeletonScaleFromFlip (Skeleton skeleton, bool flipX, bool flipY) { - skeleton.scaleX = flipX ? -baseScaleX : baseScaleX; - skeleton.scaleY = flipY ? -baseScaleY : baseScaleY; + skeleton.ScaleX = flipX ? -baseScaleX : baseScaleX; + skeleton.ScaleY = flipY ? -baseScaleY : baseScaleY; } public override void OnGraphStop (Playable playable) { @@ -99,8 +99,8 @@ namespace Spine.Unity.Playables { return; var skeleton = playableHandle.Skeleton; - skeleton.scaleX = originalScaleX; - skeleton.scaleY = originalScaleY; + skeleton.ScaleX = originalScaleX; + skeleton.ScaleY = originalScaleY; } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonExtensions.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonExtensions.cs index 17d505a0d..e2709f0c8 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonExtensions.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonExtensions.cs @@ -100,8 +100,8 @@ namespace Spine.Unity { #region Skeleton /// Sets the Skeleton's local scale using a UnityEngine.Vector2. If only individual components need to be set, set Skeleton.ScaleX or Skeleton.ScaleY. public static void SetLocalScale (this Skeleton skeleton, Vector2 scale) { - skeleton.scaleX = scale.x; - skeleton.scaleY = scale.y; + skeleton.ScaleX = scale.x; + skeleton.ScaleY = scale.y; } /// Gets the internal bone matrix as a Unity bonespace-to-skeletonspace transformation matrix. @@ -171,7 +171,7 @@ namespace Spine.Unity { /// Returns the Skeleton's local scale as a UnityEngine.Vector2. If only individual components are needed, use Skeleton.ScaleX or Skeleton.ScaleY. public static Vector2 GetLocalScale (this Skeleton skeleton) { - return new Vector2(skeleton.scaleX, skeleton.scaleY); + return new Vector2(skeleton.ScaleX, skeleton.ScaleY); } /// Calculates a 2x2 Transformation Matrix that can convert a skeleton-space position to a bone-local position. diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtility.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtility.cs index 5696e2337..39fd1a6b6 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtility.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtility.cs @@ -128,7 +128,7 @@ namespace Spine.Unity { void Update () { var skeleton = skeletonRenderer.skeleton; if (skeleton != null && boneRoot != null) { - boneRoot.localScale = new Vector3(skeleton.scaleX, skeleton.scaleY, 1f); + boneRoot.localScale = new Vector3(skeleton.ScaleX, skeleton.ScaleY, 1f); } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityBone.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityBone.cs index d949a7808..091b60fb7 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityBone.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/SkeletonUtility/SkeletonUtilityBone.cs @@ -121,7 +121,7 @@ namespace Spine.Unity { } var thisTransform = cachedTransform; - float skeletonFlipRotation = Mathf.Sign(skeleton.scaleX * skeleton.scaleY); + float skeletonFlipRotation = Mathf.Sign(skeleton.ScaleX * skeleton.ScaleY); if (mode == Mode.Follow) { switch (phase) { case UpdatePhase.Local: