|
@@ -47,11 +47,6 @@ namespace Spine.Unity {
|
|
|
public class BoneFollower : MonoBehaviour {
|
|
|
|
|
|
#region Inspector
|
|
|
- public enum ScaleMode {
|
|
|
- Local = 0,
|
|
|
- WorldUniform
|
|
|
- }
|
|
|
-
|
|
|
public SkeletonRenderer skeletonRenderer;
|
|
|
public SkeletonRenderer SkeletonRenderer {
|
|
|
get { return skeletonRenderer; }
|
|
@@ -72,12 +67,9 @@ namespace Spine.Unity {
|
|
|
[Tooltip("Follows the skeleton's flip state by controlling this Transform's local scale.")]
|
|
|
public bool followSkeletonFlip = true;
|
|
|
|
|
|
- [Tooltip("Follows the target bone's scale.")]
|
|
|
- [UnityEngine.Serialization.FormerlySerializedAs("followLocalScale")]
|
|
|
- public bool followScale = false;
|
|
|
-
|
|
|
- [Tooltip("Follows the target bone's local or uniform world scale. Note: If world scale is non-uniform/skewed, you will receive incorrect results with WorldUniform.")]
|
|
|
- public ScaleMode followScaleMode = ScaleMode.Local;
|
|
|
+ [Tooltip("Follows the target bone's local scale. BoneFollower cannot inherit world/skewed scale because of UnityEngine.Transform property limitations.")]
|
|
|
+ [UnityEngine.Serialization.FormerlySerializedAs("followScale")]
|
|
|
+ public bool followLocalScale = false;
|
|
|
|
|
|
public enum AxisOrientation {
|
|
|
XAxis = 1,
|
|
@@ -169,10 +161,7 @@ namespace Spine.Unity {
|
|
|
followZPosition ? 0f : thisTransform.localPosition.z);
|
|
|
if (followBoneRotation) {
|
|
|
float halfRotation = Mathf.Atan2(bone.c, bone.a) * 0.5f;
|
|
|
- if (followScale &&
|
|
|
- (followScaleMode == ScaleMode.Local ?
|
|
|
- (bone.scaleX < 0) :
|
|
|
- (bone.WorldScaleX < 0))) // Negate rotation from negative scaleX. Don't use negative determinant. local scaleY doesn't factor into used rotation.
|
|
|
+ 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);
|
|
@@ -208,10 +197,7 @@ namespace Spine.Unity {
|
|
|
}
|
|
|
|
|
|
Vector3 worldRotation = skeletonTransform.rotation.eulerAngles;
|
|
|
- if (followScale &&
|
|
|
- (followScaleMode == ScaleMode.Local ?
|
|
|
- (bone.scaleX < 0) :
|
|
|
- (bone.WorldScaleX < 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;
|
|
@@ -221,10 +207,7 @@ namespace Spine.Unity {
|
|
|
* skeletonLossyScale.y * parentLossyScale.y);
|
|
|
}
|
|
|
|
|
|
- Vector3 localScale = followScale ? (followScaleMode == ScaleMode.Local ?
|
|
|
- new Vector3(bone.scaleX, bone.scaleY, 1f) :
|
|
|
- new Vector3(bone.WorldScaleX, bone.WorldScaleY, 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;
|
|
|
|